GData.OAuth1Authorizer¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The human-readable, translated application name for the client. |
||
r/w |
The locale to use for network requests, in Unix locale format. |
||
r/w |
A |
||
r/w |
The proxy URI used internally for all network requests. |
||
r/w |
A timeout, in seconds, for network operations. |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class GData.OAuth1Authorizer(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
All the fields in the
GData.OAuth1Authorizer
structure are private and should never be accessed directly.New in version 0.9.0.
- classmethod new(application_name, service_type)¶
- Parameters:
application_name (
str
orNone
) – a human-readable, translated application name to use on authentication pages, orNone
service_type (
GObject.GType
) – theGObject.GType
of aGData.Service
subclass which theGData.OAuth1Authorizer
will be used with
- Returns:
a new
GData.OAuth1Authorizer
; unref withGObject.Object.unref
()- Return type:
Creates a new
GData.OAuth1Authorizer
.The
GData.AuthorizationDomains
for the given service_type (i.e. as returned byGData.Service.get_authorization_domains
()) are the ones the user will be requested to authorize access to on the page at the URI returned byGData.OAuth1Authorizer.request_authentication_uri
().The given application_name will set the value of
GData.OAuth1Authorizer
:application-name
and will be displayed to the user on authentication pages returned by Google. IfNone
is provided, the value ofGLib.get_application_name
() will be used as a fallback.New in version 0.9.0.
- classmethod new_for_authorization_domains(application_name, authorization_domains)¶
- Parameters:
application_name (
str
orNone
) – a human-readable, translated application name to use on authentication pages, orNone
authorization_domains ([
GData.AuthorizationDomain
]) – a non-empty list ofGData.AuthorizationDomains
to be authorized against by theGData.OAuth1Authorizer
- Returns:
a new
GData.OAuth1Authorizer
; unref withGObject.Object.unref
()- Return type:
Creates a new
GData.OAuth1Authorizer
. This function is intended to be used only when the default authorization domain list for a singleGData.Service
, as used byGData.OAuth1Authorizer.new
(), isn’t suitable. For example, this could be because theGData.OAuth1Authorizer
will be used with multipleGData.Service
subclasses, or because the client requires a specific set of authorization domains.The specified
GData.AuthorizationDomains
are the ones the user will be requested to authorize access to on the page at the URI returned byGData.OAuth1Authorizer.request_authentication_uri
().The given application_name will set the value of
GData.OAuth1Authorizer
:application-name
and will be displayed to the user on authentication pages returned by Google. IfNone
is provided, the value ofGLib.get_application_name
() will be used as a fallback.New in version 0.9.0.
- get_application_name()¶
-
Returns the application name being used on the authentication page at the URI returned by
GData.OAuth1Authorizer.request_authentication_uri
(); i.e. the value ofGData.OAuth1Authorizer
:application-name
.New in version 0.9.0.
- get_locale()¶
-
Returns the locale currently being used for network requests, or
None
if the locale is the default.New in version 0.9.0.
- get_proxy_resolver()¶
- Returns:
a
Gio.ProxyResolver
, orNone
- Return type:
Gets the
Gio.ProxyResolver
on theGData.OAuth1Authorizer
'sSoup.Session
.New in version 0.15.0.
- get_proxy_uri()¶
- Returns:
the proxy URI, or
None
; free withSoup.URI.free
()- Return type:
Gets the proxy URI on the
GData.OAuth1Authorizer
'sSoup.Session
.New in version 0.9.0.
Deprecated since version 0.15.0: Use
GData.OAuth1Authorizer.get_proxy_resolver
() instead, which gives more flexibility over the proxy used.
- get_timeout()¶
- Returns:
the timeout, or 0
- Return type:
Gets the
GData.OAuth1Authorizer
:timeout
property; the network timeout, in seconds.New in version 0.9.0.
- request_authentication_uri(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
the URI of an authentication page for the user to use; free with
GLib.free
()- Return type:
Requests a fresh unauthenticated token from the Google accounts service and builds and returns the URI of an authentication page for that token. This should then be presented to the user (e.g. in an embedded or stand alone web browser). The authentication page will ask the user to log in using their Google account, then ask them to grant access to the
GData.AuthorizationDomains
passed to the constructor of theGData.OAuth1Authorizer
. If the user grants access, they will be given a verifier, which can then be passed toGData.OAuth1Authorizer.request_authorization
() (along with the token and token_secret values returned by this method) to authorize the token.This method can fail if the server returns an error, but this is unlikely. If it does happen, a
GData.ServiceError.PROTOCOL_ERROR
will be raised, token and token_secret will be set toNone
andNone
will be returned.This method implements Section 2.1 and
Section 2.2 of the OAuth 1.0 protocol. When freeing token_secret, it’s advisable to set it to all zeros first, to reduce the chance of the sensitive token being recoverable from the free memory pool and (accidentally) leaked by a different part of the process. This can be achieved with the following code:
if (token_secret != NULL) { memset (token_secret, 0, strlen (token_secret)); g_free (token_secret); }
New in version 0.9.0.
- request_authentication_uri_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when building the URI is finisheduser_data (
object
orNone
) – data to pass to the callback function
Requests a fresh unauthenticated token from the Google accounts service and builds and returns the URI of an authentication page for that token. self is reffed when this method is called, so can safely be unreffed after this method returns.
For more details, see
GData.OAuth1Authorizer.request_authentication_uri
(), which is the synchronous version of this method.When the operation is finished, callback will be called. You can then call
GData.OAuth1Authorizer.request_authentication_uri_finish
() to get the results of the operation.New in version 0.9.0.
- request_authentication_uri_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
the URI of an authentication page for the user to use; free with
GLib.free
()- Return type:
Finishes an asynchronous authentication URI building operation started with
GData.OAuth1Authorizer.request_authentication_uri_async
().This method can fail if the server has returned an error, but this is unlikely. If it does happen, a
GData.ServiceError.PROTOCOL_ERROR
will be raised, token and token_secret will be set toNone
andNone
will be returned.When freeing token_secret, it’s advisable to set it to all zeros first, to reduce the chance of the sensitive token being recoverable from the free memory pool and (accidentally) leaked by a different part of the process. This can be achieved with the following code:
if (token_secret != NULL) { memset (token_secret, 0, strlen (token_secret)); g_free (token_secret); }
New in version 0.9.0.
- request_authorization(token, token_secret, verifier, cancellable)¶
- Parameters:
token (
str
) – the request token returned byGData.OAuth1Authorizer.request_authentication_uri
()token_secret (
str
) – the request token secret returned byGData.OAuth1Authorizer.request_authentication_uri
()verifier (
str
) – the verifier entered by the user from the authentication pagecancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
- Return type:
Requests authorization of the given request token from the Google accounts service using the given verifier as entered by the user from the authentication page at the URI returned by
GData.OAuth1Authorizer.request_authentication_uri
(). token and token_secret must be the same values as were returned byGData.OAuth1Authorizer.request_authentication_uri
() if it was successful.If the verifier is valid (i.e. the user granted access to the application and the Google accounts service has no reason to distrust the client),
True
will be returned and any operations performed from that point onwards onGData.Services
using thisGData.Authorizer
will be authorized.If the user denies access to the application or the Google accounts service distrusts it, a bogus verifier could be returned. In this case,
False
will be returned and aGData.ServiceError.FORBIDDEN
error will be raised.Note that if the user denies access to the application, it may be the case that they have no verifier to enter. In this case, the client can simply not call this method. The
GData.OAuth1Authorizer
stores no state for authentication operations which have succeeded in callingGData.OAuth1Authorizer.request_authentication_uri
() but not yet successfully calledGData.OAuth1Authorizer.request_authorization
().This method implements Section 2.3 of the
New in version 0.9.0.
- request_authorization_async(token, token_secret, verifier, cancellable, callback, *user_data)¶
- Parameters:
token (
str
) – the request token returned byGData.OAuth1Authorizer.request_authentication_uri
()token_secret (
str
) – the request token secret returned byGData.OAuth1Authorizer.request_authentication_uri
()verifier (
str
) – the verifier entered by the user from the authentication pagecancellable (
Gio.Cancellable
orNone
) – an optionalGio.Cancellable
, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when authorization is finisheduser_data (
object
orNone
) – data to pass to the callback function
Requests authorization of the given request token from the Google accounts service using the given verifier as entered by the user. self, token, token_secret and verifier are reffed/copied when this method is called, so can safely be freed after this method returns.
For more details, see
GData.OAuth1Authorizer.request_authorization
(), which is the synchronous version of this method.When the operation is finished, callback will be called. You can then call
GData.OAuth1Authorizer.request_authorization_finish
() to get the results of the operation.New in version 0.9.0.
- request_authorization_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
- Return type:
Finishes an asynchronous authorization operation started with
GData.OAuth1Authorizer.request_authorization_async
().New in version 0.9.0.
- set_locale(locale)¶
- Parameters:
locale (
str
orNone
) – the new locale in Unix locale format, orNone
for the default locale
Set the locale used for network requests to locale, given in standard Unix locale format. See
GData.OAuth1Authorizer
:locale
for more details.Note that while it’s possible to change the locale after sending network requests (i.e. calling
GData.OAuth1Authorizer.request_authentication_uri
() for the first time), it is unsupported, as the server-side software may behave unexpectedly. The only supported use of this method is after creation of the authorizer, but before any network requests are made.New in version 0.9.0.
- set_proxy_resolver(proxy_resolver)¶
- Parameters:
proxy_resolver (
Gio.ProxyResolver
orNone
) – aGio.ProxyResolver
, orNone
Sets the
Gio.ProxyResolver
on theSoup.Session
used internally by the givenGData.OAuth1Authorizer
.Setting this will clear the
GData.OAuth1Authorizer
:proxy-uri
property.New in version 0.15.0.
- set_proxy_uri(proxy_uri)¶
-
Sets the proxy URI on the
Soup.Session
used internally by theGData.OAuth1Authorizer
. 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.OAuth1Authorizer.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.OAuth1Authorizer
:timeout
property; the network timeout, in seconds.If timeout is 0, network operations will never time out.
New in version 0.9.0.
Property Details¶
- GData.OAuth1Authorizer.props.application_name¶
- Name:
application-name
- Type:
- Default Value:
- Flags:
The human-readable, translated application name for the client, to be presented to the user on the authentication page at the URI returned by
GData.OAuth1Authorizer.request_authentication_uri
().If
None
is provided in the constructor toGData.OAuth1Authorizer
, the value returned byGLib.get_application_name
() will be used as a fallback. Note that this may also beNone
: in this case, the authentication page will use the application name “anonymous”.New in version 0.9.0.
- GData.OAuth1Authorizer.props.locale¶
-
The locale to use for network requests, in Unix locale format. (e.g. “en_GB”, “cs”, “de_DE”.) Use
None
for the default “C” locale (typically “en_US”).This locale will be used by the server-side software to localise the authentication and authorization pages at the URI returned by
GData.OAuth1Authorizer.request_authentication_uri
().The server-side behaviour is undefined if it doesn’t support a given locale.
New in version 0.9.0.
- GData.OAuth1Authorizer.props.proxy_resolver¶
- Name:
proxy-resolver
- Type:
- Default Value:
- Flags:
The
Gio.ProxyResolver
used to determine a proxy URI. Setting this will clear theGData.OAuth1Authorizer
:proxy-uri
property.New in version 0.15.0.
- GData.OAuth1Authorizer.props.proxy_uri¶
-
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.OAuth1Authorizer.props.timeout¶
-
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.