![]() |
![]() |
![]() |
GNOME Online Accounts Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
GoaOAuthProvider; struct GoaOAuthProviderClass; const gchar * goa_oauth_provider_get_request_uri (GoaOAuthProvider *provider
); gchar ** goa_oauth_provider_get_request_uri_params (GoaOAuthProvider *provider
); const gchar * goa_oauth_provider_get_authorization_uri (GoaOAuthProvider *provider
); const gchar * goa_oauth_provider_get_token_uri (GoaOAuthProvider *provider
); const gchar * goa_oauth_provider_get_callback_uri (GoaOAuthProvider *provider
); const gchar * goa_oauth_provider_get_consumer_key (GoaOAuthProvider *provider
); const gchar * goa_oauth_provider_get_consumer_secret (GoaOAuthProvider *provider
); gchar * goa_oauth_provider_build_authorization_uri (GoaOAuthProvider *provider
,const gchar *authorization_uri
,const gchar *escaped_oauth_token
); gboolean goa_oauth_provider_get_use_external_browser (GoaOAuthProvider *provider
); void goa_oauth_provider_add_account_key_values (GoaOAuthProvider *provider
,GVariantBuilder *builder
); gchar * goa_oauth_provider_get_identity_sync (GoaOAuthProvider *provider
,const gchar *access_token
,const gchar *access_token_secret
,gchar **out_presentation_identity
,GCancellable *cancellable
,GError **error
); gchar * goa_oauth_provider_get_access_token_sync (GoaOAuthProvider *provider
,GoaObject *object
,gboolean force_refresh
,gchar **out_access_token_secret
,gint *out_access_token_expires_in
,GCancellable *cancellable
,GError **error
);
GObject +----GoaProvider +----GoaOAuthProvider +----GoaGoogleProvider +----GoaYahooProvider +----GoaTwitterProvider
GoaOAuthProvider is an abstract base class for OAuth 1.0a compliant implementations as defined by RFC 5849. Additionally, the code works with providers implementing OAuth Session 1.0 Draft 1 for refreshing access tokens.
Subclasses must implement GoaOAuthProviderClass.get_consumer_key, GoaOAuthProviderClass.get_consumer_secret, GoaOAuthProviderClass.get_request_uri, GoaOAuthProviderClass.get_authorization_uri, GoaOAuthProviderClass.get_token_uri, GoaOAuthProviderClass.get_callback_uri and GoaOAuthProviderClass.get_identity_sync methods.
Additionally, the GoaProviderClass.get_provider_type, GoaProviderClass.get_provider_name, GoaProviderClass.build_object (this should chain up to its parent class) methods must be implemented.
Note that the GoaProviderClass.add_account, GoaProviderClass.refresh_account and GoaProviderClass.ensure_credentials_sync methods do not need to be implemented - this type implements these methods.
typedef struct _GoaOAuthProvider GoaOAuthProvider;
The GoaOAuthProvider structure contains only private data and should only be accessed using the provided API.
struct GoaOAuthProviderClass { GoaProviderClass parent_class; /* pure virtual */ const gchar *(*get_consumer_key) (GoaOAuthProvider *provider); const gchar *(*get_consumer_secret) (GoaOAuthProvider *provider); const gchar *(*get_request_uri) (GoaOAuthProvider *provider); const gchar *(*get_authorization_uri) (GoaOAuthProvider *provider); const gchar *(*get_token_uri) (GoaOAuthProvider *provider); const gchar *(*get_callback_uri) (GoaOAuthProvider *provider); gchar *(*get_identity_sync) (GoaOAuthProvider *provider, const gchar *access_token, const gchar *access_token_secret, gchar **out_presentation_identity, GCancellable *cancellable, GError **error); /* virtual but with default implementation */ gchar *(*build_authorization_uri) (GoaOAuthProvider *provider, const gchar *authorization_uri, const gchar *escaped_oauth_token); gboolean (*get_use_external_browser) (GoaOAuthProvider *provider); gchar **(*get_request_uri_params) (GoaOAuthProvider *provider); void (*add_account_key_values) (GoaOAuthProvider *provider, GVariantBuilder *builder); };
Class structure for GoaOAuthProvider.
GoaProviderClass |
The parent class. |
Virtual function for goa_oauth_provider_get_consumer_key() . |
|
Virtual function for goa_oauth_provider_get_consumer_secret() . |
|
Virtual function for goa_oauth_provider_get_request_uri() . |
|
Virtual function for goa_oauth_provider_get_authorization_uri() . |
|
Virtual function for goa_oauth_provider_get_token_uri() . |
|
Virtual function for goa_oauth_provider_get_callback_uri() . |
|
Virtual function for goa_oauth_provider_get_identity_sync() . |
|
Virtual function for goa_oauth_provider_build_authorization_uri() . |
|
Virtual function for goa_oauth_provider_get_use_external_browser() . |
|
Virtual function for goa_oauth_provider_get_request_uri_params() . |
|
Virtual function for goa_oauth_provider_add_account_key_values() . |
const gchar * goa_oauth_provider_get_request_uri (GoaOAuthProvider *provider
);
Gets the request uri.
http://tools.ietf.org/html/rfc5849section-2.1
This is a pure virtual method - a subclass must provide an implementation.
|
A GoaOAuthProvider. |
Returns : |
A string owned by provider - do not free. [transfer none]
|
gchar ** goa_oauth_provider_get_request_uri_params
(GoaOAuthProvider *provider
);
Gets additional parameters for the request URI.
http://tools.ietf.org/html/rfc5849section-2.1
This is a virtual method where the default implementation returns
NULL
.
|
A GoaOAuthProvider. |
Returns : |
NULL (for no parameters) or a
NULL -terminated array of (key, value) pairs that will be added to
the URI. The caller will free the returned value with g_strfreev() . [transfer full]
|
const gchar * goa_oauth_provider_get_authorization_uri
(GoaOAuthProvider *provider
);
Gets the authorization uri.
http://tools.ietf.org/html/rfc5849section-2.2
This is a pure virtual method - a subclass must provide an implementation.
|
A GoaOAuthProvider. |
Returns : |
A string owned by provider - do not free. [transfer none]
|
const gchar * goa_oauth_provider_get_token_uri (GoaOAuthProvider *provider
);
Gets the token uri.
http://tools.ietf.org/html/rfc5849section-2.3
This is a pure virtual method - a subclass must provide an implementation.
|
A GoaOAuthProvider. |
Returns : |
A string owned by provider - do not free. [transfer none]
|
const gchar * goa_oauth_provider_get_callback_uri (GoaOAuthProvider *provider
);
Gets the callback uri.
http://tools.ietf.org/html/rfc5849section-2.1
This is a pure virtual method - a subclass must provide an implementation.
|
A GoaOAuthProvider. |
Returns : |
A string owned by provider - do not free. [transfer none]
|
const gchar * goa_oauth_provider_get_consumer_key (GoaOAuthProvider *provider
);
Gets the consumer key identifying the client.
This is a pure virtual method - a subclass must provide an implementation.
|
A GoaOAuthProvider. |
Returns : |
A string owned by provider - do not free. [transfer none]
|
const gchar * goa_oauth_provider_get_consumer_secret
(GoaOAuthProvider *provider
);
Gets the consumer secret identifying the client.
This is a pure virtual method - a subclass must provide an implementation.
|
A GoaOAuthProvider. |
Returns : |
A string owned by provider - do not free. [transfer none]
|
gchar * goa_oauth_provider_build_authorization_uri (GoaOAuthProvider *provider
,const gchar *authorization_uri
,const gchar *escaped_oauth_token
);
Builds the URI that can be opened in a web browser (or embedded web browser widget) to start authenticating an user.
The default implementation just returns the expected URI
(e.g. http://example.com/dialog/oauth?auth_token=1234567890
)
- override (and chain up) if you e.g. need to to pass additional
parameters.
The authorization_uri
parameter originate from the result of the
the goa_oauth_provider_get_authorization_uri()
method. The
escaped_oauth_token
parameter is the temporary credentials identifier
escaped using g_uri_escape_string()
.
|
A GoaOAuthProvider. |
|
An authorization URI. |
|
An escaped oauth token. |
Returns : |
An authorization URI that must be freed with g_free() . [transfer full]
|
gboolean goa_oauth_provider_get_use_external_browser
(GoaOAuthProvider *provider
);
Returns whether an external browser (the users default browser) should be used for user interaction.
If an external browser is used, then the dialogs presented in
goa_provider_add_account()
and
goa_provider_refresh_account()
will show a simple "Paste
authorization code here" instructions along with an entry and
button.
This is a virtual method where the default implementation returns
FALSE
.
|
A GoaOAuthProvider. |
Returns : |
TRUE if the user interaction should happen in an external
browser, FALSE to use an embedded browser widget. |
void goa_oauth_provider_add_account_key_values (GoaOAuthProvider *provider
,GVariantBuilder *builder
);
Hook for implementations to add key/value pairs to the key-file when creating an account.
This is a virtual method where the default implementation does nothing.
|
A GoaProvider. |
|
A GVariantBuilder for a a{ss} variant. |
gchar * goa_oauth_provider_get_identity_sync (GoaOAuthProvider *provider
,const gchar *access_token
,const gchar *access_token_secret
,gchar **out_presentation_identity
,GCancellable *cancellable
,GError **error
);
Method that returns the identity corresponding to access_token
and
access_token_secret
.
The identity is needed because all authentication happens out of band. In addition to the identity, an implementation also returns a presentation identity that is more suitable for presentation (the identity could be a GUID for example).
The calling thread is blocked while the identity is obtained.
This is a pure virtual method - a subclass must provide an implementation.
|
A GoaOAuthProvider. |
|
A valid OAuth 1.0 access token. |
|
The valid secret for access_token . |
|
Return location for presentation identity or NULL . [out]
|
|
A GCancellable or NULL . [allow-none]
|
|
Return location for error or NULL . |
Returns : |
The identity or NULL if error is set. The returned string
must be freed with g_free() . |
gchar * goa_oauth_provider_get_access_token_sync (GoaOAuthProvider *provider
,GoaObject *object
,gboolean force_refresh
,gchar **out_access_token_secret
,gint *out_access_token_expires_in
,GCancellable *cancellable
,GError **error
);
Synchronously gets an access token for object
. The calling thread
is blocked while the operation is pending.
The resulting token is typically read from the local cache so most of the time only a local roundtrip to the storage for the token cache (e.g. gnome-keyring-daemon) is needed. However, the operation may involve refreshing the token with the service provider so a full network round-trip may be needed.
Note that multiple calls are serialized to avoid multiple outstanding requests to the service provider.
This operation may fail if e.g. unable to refresh the credentials
or if network connectivity is not available. Note that even if a
token is returned, the returned token isn't guaranteed to work -
use goa_provider_ensure_credentials_sync()
if you need
stronger guarantees.
|
A GoaOAuthProvider. |
|
A GoaObject. |
|
If set to TRUE , forces a refresh of the access token, if possible. |
|
The secret for the return access token. [out] |
|
Return location for how many seconds the returned token is valid for (0 if unknown) or NULL . [out]
|
|
A GCancellable or NULL . [allow-none]
|
|
Return location for error or NULL . |
Returns : |
The access token or NULL if error is set. The returned
string must be freed with g_free() . |