GData.ClientLoginAuthorizer

g GData.Authorizer GData.Authorizer GData.ClientLoginAuthorizer GData.ClientLoginAuthorizer GData.Authorizer->GData.ClientLoginAuthorizer GObject.GInterface GObject.GInterface GObject.GInterface->GData.Authorizer GObject.Object GObject.Object GObject.Object->GData.ClientLoginAuthorizer

Subclasses:

None

Methods

Inherited:

GObject.Object (37), GData.Authorizer (5)

Structs:

GObject.ObjectClass (5)

class

new (client_id, service_type)

class

new_for_authorization_domains (client_id, authorization_domains)

authenticate (username, password, cancellable)

authenticate_async (username, password, cancellable, callback, *user_data)

authenticate_finish (async_result)

get_client_id ()

get_password ()

get_proxy_resolver ()

get_proxy_uri ()

get_timeout ()

get_username ()

set_proxy_resolver (proxy_resolver)

set_proxy_uri (proxy_uri)

set_timeout (timeout)

Virtual Methods

Inherited:

GObject.Object (7), GData.Authorizer (5)

Properties

Name

Type

Flags

Short Description

client-id

str

r/w/co

A client ID for your application.

password

str

r

The user’s account password for authentication.

proxy-resolver

Gio.ProxyResolver

r/w

A Gio.ProxyResolver used to determine a proxy URI.

proxy-uri

Soup.URI

r/w

The proxy URI used internally for all network requests. deprecated

timeout

int

r/w

A timeout, in seconds, for network operations.

username

str

r

The user’s Google username for authentication.

Signals

Inherited:

GObject.Object (1)

Name

Short Description

captcha-challenge

The GData.ClientLoginAuthorizer ::captcha-challenge signal is emitted during the authentication process if the authorizer requires a CAPTCHA to be completed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class GData.ClientLoginAuthorizer(**kwargs)
Bases:

GObject.Object, GData.Authorizer

Abstract:

No

Structure:

GData.ClientLoginAuthorizerClass

All the fields in the GData.ClientLoginAuthorizer structure are private and should never be accessed directly.

New in version 0.9.0.

classmethod new(client_id, service_type)
Parameters:
Returns:

a new GData.ClientLoginAuthorizer, or None; unref with GObject.Object.unref()

Return type:

GData.ClientLoginAuthorizer

Creates a new GData.ClientLoginAuthorizer. The client_id must be unique for your application, and as registered with Google.

The GData.AuthorizationDomains for the given service_type (i.e. as returned by GData.Service.get_authorization_domains()) are the ones the user will be logged in to using the provided username and password when GData.ClientLoginAuthorizer.authenticate() is called. Note that the same username and password will be used for all domains.

New in version 0.9.0.

classmethod new_for_authorization_domains(client_id, authorization_domains)
Parameters:
Returns:

a new GData.ClientLoginAuthorizer, or None; unref with GObject.Object.unref()

Return type:

GData.ClientLoginAuthorizer

Creates a new GData.ClientLoginAuthorizer. The client_id must be unique for your application, and as registered with Google. This function is intended to be used only when the default authorization domain list for a single GData.Service, as used by GData.ClientLoginAuthorizer.new(), isn’t suitable. For example, this could be because the GData.ClientLoginAuthorizer will be used with multiple GData.Service subclasses, or because the client requires a specific set of authorization domains.

The specified GData.AuthorizationDomains are the ones the user will be logged in to using the provided username and password when GData.ClientLoginAuthorizer.authenticate() is called. Note that the same username and password will be used for all domains.

New in version 0.9.0.

authenticate(username, password, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True if authentication and authorization was successful against all the services, False otherwise

Return type:

bool

Authenticates the GData.ClientLoginAuthorizer with the Google Accounts service using username and password and authorizes it against all the service types passed to GData.ClientLoginAuthorizer.new(); i.e. logs into the service with the given user account. username should be a full e-mail address (e.g. john.smith\@gmail.com). If a full e-mail address is not given, username will have \@gmail.com appended to create an e-mail address

If cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

If the operation errors or is cancelled part-way through, GData.Authorizer.is_authorized_for_domain() is guaranteed to return False for all GData.AuthorizationDomains, even if authentication has succeeded for some of them already.

A GData.ClientLoginAuthorizerError.BAD_AUTHENTICATION will be returned if authentication failed due to an incorrect username or password. Other GData.ClientLoginAuthorizerError errors can be returned for other conditions.

If the service requires a CAPTCHA to be completed, the GData.ClientLoginAuthorizer ::captcha-challenge signal will be emitted. The return value from a signal handler for the signal should be a newly allocated string containing the text from the image. If the text is None or empty, authentication will fail with a GData.ClientLoginAuthorizerError.CAPTCHA_REQUIRED error. Otherwise, authentication will be automatically and transparently restarted with the new CAPTCHA details.

A GData.ServiceError.PROTOCOL_ERROR will be returned if the server’s responses were invalid.

New in version 0.9.0.

authenticate_async(username, password, cancellable, callback, *user_data)
Parameters:

Authenticates the GData.ClientLoginAuthorizer with the Google accounts service using the given username and password. self, username and password are all reffed/copied when this function is called, so can safely be freed after this function returns.

For more details, see GData.ClientLoginAuthorizer.authenticate(), which is the synchronous version of this function.

When the operation is finished, callback will be called. You can then call GData.ClientLoginAuthorizer.authenticate_finish() to get the results of the operation.

New in version 0.9.0.

authenticate_finish(async_result)
Parameters:

async_result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if authentication was successful, False otherwise

Return type:

bool

Finishes an asynchronous authentication operation started with GData.ClientLoginAuthorizer.authenticate_async().

New in version 0.9.0.

get_client_id()
Returns:

the authorizer’s client ID

Return type:

str

Returns the authorizer’s client ID, as specified on constructing the GData.ClientLoginAuthorizer.

New in version 0.9.0.

get_password()
Returns:

the password of the currently authenticated user, or None

Return type:

str

Returns the password of the currently authenticated user, or None if nobody is authenticated.

It is not safe to call this while an authentication operation is ongoing.

If libgdata is compiled with libgcr support, the password will be stored in non-pageable memory. Since this function doesn’t return a copy of the password, the returned value is guaranteed to not hit disk. It’s advised that any copies of the password made in client programs also use non-pageable memory.

New in version 0.9.0.

get_proxy_resolver()
Returns:

a Gio.ProxyResolver, or None

Return type:

Gio.ProxyResolver or None

Gets the Gio.ProxyResolver on the GData.ClientLoginAuthorizer's Soup.Session.

New in version 0.15.0.

get_proxy_uri()
Returns:

the proxy URI, or None; free with Soup.URI.free()

Return type:

Soup.URI

Gets the proxy URI on the GData.ClientLoginAuthorizer's Soup.Session.

New in version 0.9.0.

Deprecated since version 0.15.0: Use GData.ClientLoginAuthorizer.get_proxy_resolver() instead, which gives more flexibility over the proxy used.

get_timeout()
Returns:

the timeout, or 0

Return type:

int

Gets the GData.ClientLoginAuthorizer :timeout property; the network timeout, in seconds.

New in version 0.9.0.

get_username()
Returns:

the username of the currently authenticated user, or None

Return type:

str

Returns the username of the currently authenticated user, or None if nobody is authenticated.

It is not safe to call this while an authentication operation is ongoing.

New in version 0.9.0.

set_proxy_resolver(proxy_resolver)
Parameters:

proxy_resolver (Gio.ProxyResolver or None) – a Gio.ProxyResolver, or None

Sets the Gio.ProxyResolver on the Soup.Session used internally by the given GData.ClientLoginAuthorizer.

Setting this will clear the GData.ClientLoginAuthorizer :proxy-uri property.

New in version 0.15.0.

set_proxy_uri(proxy_uri)
Parameters:

proxy_uri (Soup.URI or None) – the proxy URI, or None

Sets the proxy URI on the Soup.Session used internally by the GData.ClientLoginAuthorizer. This forces all requests through the given proxy.

If proxy_uri is None, no proxy will be used.

New in version 0.9.0.

Deprecated since version 0.15.0: Use GData.ClientLoginAuthorizer.set_proxy_resolver() instead, which gives more flexibility over the proxy used.

set_timeout(timeout)
Parameters:

timeout (int) – the timeout, or 0

Sets the GData.ClientLoginAuthorizer :timeout property; the network timeout, in seconds.

If timeout is 0, network operations will never time out.

New in version 0.9.0.

Signal Details

GData.ClientLoginAuthorizer.signals.captcha_challenge(client_login_authorizer, uri)
Signal Name:

captcha-challenge

Flags:

RUN_LAST

Parameters:
  • client_login_authorizer (GData.ClientLoginAuthorizer) – The object which received the signal

  • uri (str) – the URI of the CAPTCHA image to be used

Returns:

a newly allocated string containing the text in the CAPTCHA image

Return type:

str

The GData.ClientLoginAuthorizer ::captcha-challenge signal is emitted during the authentication process if the authorizer requires a CAPTCHA to be completed. The URI of a CAPTCHA image is given, and the program should display this to the user, and return their response (the text displayed in the image). There is no timeout imposed by the library for the response.

New in version 0.9.0.

Property Details

GData.ClientLoginAuthorizer.props.client_id
Name:

client-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

A client ID for your application (see the

reference documentation). It is recommended that the ID is of the form company name-application name- version ID.

New in version 0.9.0.

GData.ClientLoginAuthorizer.props.password
Name:

password

Type:

str

Default Value:

None

Flags:

READABLE

The user’s account password for authentication.

This will only be set after authentication using GData.ClientLoginAuthorizer.authenticate() is completed successfully. It will then be set to the password passed to GData.ClientLoginAuthorizer.authenticate(), and a GObject.Object ::notify signal will be emitted. If authentication fails, it will be set to None.

If libgdata is compiled with libgcr support, the password will be stored in non-pageable memory. However, if it is retrieved using g_object_get() (or related functions) it will be copied to non-pageable memory and could end up being written to disk. Accessing the password using GData.ClientLoginAuthorizer.get_password() will not perform any copies, and so maintains privacy.

New in version 0.9.0.

GData.ClientLoginAuthorizer.props.proxy_resolver
Name:

proxy-resolver

Type:

Gio.ProxyResolver

Default Value:

None

Flags:

READABLE, WRITABLE

The Gio.ProxyResolver used to determine a proxy URI. Setting this will clear the GData.ClientLoginAuthorizer :proxy-uri property.

New in version 0.15.0.

GData.ClientLoginAuthorizer.props.proxy_uri
Name:

proxy-uri

Type:

Soup.URI

Default Value:

None

Flags:

READABLE, WRITABLE

The proxy URI used internally for all network requests.

New in version 0.9.0.

Deprecated since version 0.15.0: Use GData.ClientLoginAuthorizer :proxy-resolver instead, which gives more flexibility over the proxy used.

GData.ClientLoginAuthorizer.props.timeout
Name:

timeout

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

A timeout, in seconds, for network operations. If the timeout is exceeded, the operation will be cancelled and GData.ServiceError.NETWORK_ERROR will be returned.

If the timeout is 0, operations will never time out.

New in version 0.9.0.

GData.ClientLoginAuthorizer.props.username
Name:

username

Type:

str

Default Value:

None

Flags:

READABLE

The user’s Google username for authentication. This will always be a full e-mail address.

This will only be set after authentication using GData.ClientLoginAuthorizer.authenticate() is completed successfully. It will then be set to the username passed to GData.ClientLoginAuthorizer.authenticate(), and a GObject.Object ::notify signal will be emitted. If authentication fails, it will be set to None.

New in version 0.9.0.