Top |
Functions
const gchar * | goa_oauth_provider_get_request_uri () |
gchar ** | goa_oauth_provider_get_request_uri_params () |
const gchar * | goa_oauth_provider_get_authorization_uri () |
const gchar * | goa_oauth_provider_get_token_uri () |
const gchar * | goa_oauth_provider_get_callback_uri () |
const gchar * | goa_oauth_provider_get_consumer_key () |
const gchar * | goa_oauth_provider_get_consumer_secret () |
gchar * | goa_oauth_provider_build_authorization_uri () |
gboolean | goa_oauth_provider_get_use_mobile_browser () |
gboolean | goa_oauth_provider_is_deny_node () |
gboolean | goa_oauth_provider_is_identity_node () |
gboolean | goa_oauth_provider_is_password_node () |
void | goa_oauth_provider_add_account_key_values () |
gchar * | goa_oauth_provider_get_identity_sync () |
gchar * | goa_oauth_provider_get_access_token_sync () |
gchar * | goa_oauth_provider_parse_request_token_error () |
Description
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.
Functions
goa_oauth_provider_get_request_uri ()
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.
goa_oauth_provider_get_request_uri_params ()
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
.
goa_oauth_provider_get_authorization_uri ()
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.
goa_oauth_provider_get_token_uri ()
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.
goa_oauth_provider_get_callback_uri ()
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.
goa_oauth_provider_get_consumer_key ()
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.
goa_oauth_provider_get_consumer_secret ()
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.
goa_oauth_provider_build_authorization_uri ()
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()
.
goa_oauth_provider_get_use_mobile_browser ()
gboolean
goa_oauth_provider_get_use_mobile_browser
(GoaOAuthProvider *provider
);
Returns whether there is a need for the embedded browser to identify itself as running on a mobile phone in order to get a more compact version of the approval page.
This is a virtual method where the default implementation returns
FALSE
.
goa_oauth_provider_is_deny_node ()
gboolean goa_oauth_provider_is_deny_node (GoaOAuthProvider *provider
,WebKitDOMNode *node
);
Checks whether node
is the HTML UI element that the user can use
to deny permission to access his account. Usually they are either a
WebKitDOMHTMLButtonElement or a WebKitDOMHTMLInputElement.
Please note that providers may have multiple such elements in their UI and this method should catch all of them.
This is a virtual method where the default implementation returns
FALSE
.
goa_oauth_provider_is_identity_node ()
gboolean goa_oauth_provider_is_identity_node (GoaOAuthProvider *provider
,WebKitDOMHTMLInputElement *element
);
Checks whether element
is the HTML UI element that the user can
use to identify herself at the provider.
This is a pure virtual method - a subclass must provide an implementation.
goa_oauth_provider_is_password_node ()
gboolean goa_oauth_provider_is_password_node (GoaOAuthProvider *provider
,WebKitDOMHTMLInputElement *element
);
Checks whether element
is the HTML UI element that the user can
use to enter her password. This can be used to offer a
GoaPasswordBased interface by saving the user's
password. Providers usually frown upon doing this, so this is not
recommended.
This is a virtual method where the default implementation returns
FALSE
.
goa_oauth_provider_add_account_key_values ()
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.
goa_oauth_provider_get_identity_sync ()
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.
goa_oauth_provider_get_access_token_sync ()
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.
Parameters
provider |
||
object |
A GoaObject. |
|
force_refresh |
If set to |
|
out_access_token_secret |
The secret for the return access token. |
[out] |
out_access_token_expires_in |
Return location for how many seconds the returned token is valid for (0 if unknown) or |
[out] |
cancellable |
A GCancellable or |
[allow-none] |
error |
Return location for error or |
goa_oauth_provider_parse_request_token_error ()
gchar * goa_oauth_provider_parse_request_token_error (GoaOAuthProvider *provider
,RestProxyCall *call
);
Tries to parse the headers and payload within call
to provide a
human readable error message in case the request token could not
be fetched.
This is a pure virtual method - a subclass must provide an implementation.
Types and Values
GoaOAuthProvider
typedef struct _GoaOAuthProvider GoaOAuthProvider;
The GoaOAuthProvider structure contains only private data and should only be accessed using the provided API.
struct GoaOAuthProviderClass
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); gchar *(*parse_request_token_error) (GoaOAuthProvider *provider, RestProxyCall *call); /* virtual but with default implementation */ gchar *(*build_authorization_uri) (GoaOAuthProvider *provider, const gchar *authorization_uri, const gchar *escaped_oauth_token); gboolean (*get_use_mobile_browser) (GoaOAuthProvider *provider); gchar **(*get_request_uri_params) (GoaOAuthProvider *provider); void (*add_account_key_values) (GoaOAuthProvider *provider, GVariantBuilder *builder); /* pure virtual */ gboolean (*is_identity_node) (GoaOAuthProvider *provider, WebKitDOMHTMLInputElement *element); /* virtual but with default implementation */ gboolean (*is_deny_node) (GoaOAuthProvider *provider, WebKitDOMNode *node); gboolean (*is_password_node) (GoaOAuthProvider *provider, WebKitDOMHTMLInputElement *element); };
Class structure for GoaOAuthProvider.
Members
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |
||
Virtual function for |