GData.Authorizer

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

Implementations:

GData.ClientLoginAuthorizer, GData.GoaAuthorizer, GData.OAuth1Authorizer, GData.OAuth2Authorizer

Methods

is_authorized_for_domain (domain)

process_request (domain, message)

refresh_authorization (cancellable)

refresh_authorization_async (cancellable, callback, *user_data)

refresh_authorization_finish (async_result)

Virtual Methods

do_is_authorized_for_domain (domain)

do_process_request (domain, message)

do_refresh_authorization (cancellable)

do_refresh_authorization_async (cancellable, callback, *user_data)

do_refresh_authorization_finish (async_result)

Properties

None

Signals

None

Fields

None

Class Details

class GData.Authorizer
Bases:

GObject.GInterface

Structure:

GData.AuthorizerInterface

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

New in version 0.9.0.

is_authorized_for_domain(domain)
Parameters:

domain (GData.AuthorizationDomain) – the GData.AuthorizationDomain to check against

Returns:

True if the GData.Authorizer has been authorized to access domain, False otherwise

Return type:

bool

Returns whether the GData.Authorizer instance believes it’s currently authorized to access the given domain. Note that this will not perform any network requests, and will just look up the result in the GData.Authorizer's local cache of authorizations. This means that the result may be out of date, as the server may have since invalidated the authorization. If the GData.Authorizer class supports timeouts and TTLs on authorizations, they will not be taken into account; this method effectively returns whether the last successful authorization operation performed on the GData.Authorizer included domain in the list of requested authorization domains.

Note that None may be passed as the GData.Authorizer, in which case False will always be returned, regardless of the domain. This is for convenience of checking whether a domain is authorized by the GData.Authorizer returned by GData.Service.get_authorizer(), which may be None. For example:

if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (my_service), my_domain) == TRUE) {
    /<!-- -->* Code to execute only if we're authorized for the given domain *<!-- -->/
}

This method is thread safe.

New in version 0.9.0.

process_request(domain, message)
Parameters:

Processes message, adding all the necessary extra headers and parameters to ensure that it’s correctly authenticated and authorized under the given domain for the online service. Basically, if a query is not processed by calling this method on it, it will be sent to the online service as if it’s a query from a non-logged-in user. Similarly, if the GData.Authorizer isn’t authenticated or authorized (for domain), no changes will be made to the message.

domain may be None if the request doesn’t require authorization.

This modifies message in place.

This method is thread safe.

New in version 0.9.0.

refresh_authorization(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, or None

Raises:

GLib.Error

Returns:

True if an authorization refresh was attempted and was successful, False if a refresh wasn’t attempted or was unsuccessful

Return type:

bool

Forces the GData.Authorizer to refresh any authorization tokens it holds with the online service. This should typically be called when a GData.Service query returns GData.ServiceError.AUTHENTICATION_REQUIRED, and is already called transparently by methods such as GData.Service.query() and GData.Service.insert_entry() (see their documentation for more details).

If re-authorization is successful, it’s guaranteed that by the time this method returns, the properties containing the relevant authorization tokens on the GData.Authorizer instance will have been updated.

If False is returned, error will be set if (and only if) it’s due to a refresh being attempted and failing. If a refresh is not attempted, False will be returned but error will not be set.

If the GData.Authorizer has not been previously authenticated or authorized (using the class’ specific methods), no authorization will be attempted, False will be returned immediately and error will not be set.

Some GData.Authorizer implementations may not support refreshing authorization tokens at all; for example if doing so requires user interaction. False will be returned immediately in that case and error will not be set.

This method is thread safe.

New in version 0.9.0.

refresh_authorization_async(cancellable, callback, *user_data)
Parameters:

Forces the GData.Authorizer to refresh any authorization tokens it holds with the online service. self and cancellable are reffed when this method is called, so can safely be freed after this method returns.

For more details, see GData.Authorizer.refresh_authorization(), which is the synchronous version of this method. If the GData.Authorizer class doesn’t implement GData.AuthorizerInterface.refresh_authorization_async but does implement GData.AuthorizerInterface.refresh_authorization, the latter will be called from a new thread to make it asynchronous.

When the authorization refresh operation is finished, callback will be called. You can then call GData.Authorizer.refresh_authorization_finish() to get the results of the operation.

This method is thread safe.

New in version 0.9.0.

refresh_authorization_finish(async_result)
Parameters:

async_result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if an authorization refresh was attempted and was successful, False if a refresh wasn’t attempted or was unsuccessful

Return type:

bool

Finishes an asynchronous authorization refresh operation for the GData.Authorizer, as started with GData.Authorizer.refresh_authorization_async().

This method is thread safe.

New in version 0.9.0.

do_is_authorized_for_domain(domain) virtual
Parameters:

domain (GData.AuthorizationDomain) – the GData.AuthorizationDomain to check against

Returns:

True if the GData.Authorizer has been authorized to access domain, False otherwise

Return type:

bool

Returns whether the GData.Authorizer instance believes it’s currently authorized to access the given domain. Note that this will not perform any network requests, and will just look up the result in the GData.Authorizer's local cache of authorizations. This means that the result may be out of date, as the server may have since invalidated the authorization. If the GData.Authorizer class supports timeouts and TTLs on authorizations, they will not be taken into account; this method effectively returns whether the last successful authorization operation performed on the GData.Authorizer included domain in the list of requested authorization domains.

Note that None may be passed as the GData.Authorizer, in which case False will always be returned, regardless of the domain. This is for convenience of checking whether a domain is authorized by the GData.Authorizer returned by GData.Service.get_authorizer(), which may be None. For example:

if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (my_service), my_domain) == TRUE) {
    /<!-- -->* Code to execute only if we're authorized for the given domain *<!-- -->/
}

This method is thread safe.

New in version 0.9.0.

do_process_request(domain, message) virtual
Parameters:

Processes message, adding all the necessary extra headers and parameters to ensure that it’s correctly authenticated and authorized under the given domain for the online service. Basically, if a query is not processed by calling this method on it, it will be sent to the online service as if it’s a query from a non-logged-in user. Similarly, if the GData.Authorizer isn’t authenticated or authorized (for domain), no changes will be made to the message.

domain may be None if the request doesn’t require authorization.

This modifies message in place.

This method is thread safe.

New in version 0.9.0.

do_refresh_authorization(cancellable) virtual
Parameters:

cancellable (Gio.Cancellable or None) – optional Gio.Cancellable object, or None

Returns:

True if an authorization refresh was attempted and was successful, False if a refresh wasn’t attempted or was unsuccessful

Return type:

bool

Forces the GData.Authorizer to refresh any authorization tokens it holds with the online service. This should typically be called when a GData.Service query returns GData.ServiceError.AUTHENTICATION_REQUIRED, and is already called transparently by methods such as GData.Service.query() and GData.Service.insert_entry() (see their documentation for more details).

If re-authorization is successful, it’s guaranteed that by the time this method returns, the properties containing the relevant authorization tokens on the GData.Authorizer instance will have been updated.

If False is returned, error will be set if (and only if) it’s due to a refresh being attempted and failing. If a refresh is not attempted, False will be returned but error will not be set.

If the GData.Authorizer has not been previously authenticated or authorized (using the class’ specific methods), no authorization will be attempted, False will be returned immediately and error will not be set.

Some GData.Authorizer implementations may not support refreshing authorization tokens at all; for example if doing so requires user interaction. False will be returned immediately in that case and error will not be set.

This method is thread safe.

New in version 0.9.0.

do_refresh_authorization_async(cancellable, callback, *user_data) virtual
Parameters:

Forces the GData.Authorizer to refresh any authorization tokens it holds with the online service. self and cancellable are reffed when this method is called, so can safely be freed after this method returns.

For more details, see GData.Authorizer.refresh_authorization(), which is the synchronous version of this method. If the GData.Authorizer class doesn’t implement GData.AuthorizerInterface.refresh_authorization_async but does implement GData.AuthorizerInterface.refresh_authorization, the latter will be called from a new thread to make it asynchronous.

When the authorization refresh operation is finished, callback will be called. You can then call GData.Authorizer.refresh_authorization_finish() to get the results of the operation.

This method is thread safe.

New in version 0.9.0.

do_refresh_authorization_finish(async_result) virtual
Parameters:

async_result (Gio.AsyncResult) – a Gio.AsyncResult

Returns:

True if an authorization refresh was attempted and was successful, False if a refresh wasn’t attempted or was unsuccessful

Return type:

bool

Finishes an asynchronous authorization refresh operation for the GData.Authorizer, as started with GData.Authorizer.refresh_authorization_async().

This method is thread safe.

New in version 0.9.0.