Quark  0.1
OAuth2Authenticator Class Reference

An object for performing OAuth2 authorizations for accessing Google APIs. More...

#include <OAuth2Authenticator.h++>

Inheritance diagram for OAuth2Authenticator:

Signals

void accessTokenError (const QString &error)
 Emitted when there is an error obtaining an access token. More...
 
void accessTokenReceived ()
 Emitted when an access token has been received. More...
 

Public Member Functions

 OAuth2Authenticator (QNetworkAccessManager *networkAccess, const QString &clientID, const QString &clientSecret, QObject *parent=NULL)
 Constructs a new OAuth2Authenticator with the given attributes. More...
 
virtual ~OAuth2Authenticator ()
 Destructor. More...
 
QUrl buildAuthUrl (const QStringList &authScopes)
 Constructs the authorization URL at which the user will be prompted to log in to their Google account and/or approve/deny an authorization request. More...
 
bool requestAccessToken (const QString &authorizationCode)
 Issues a request to obtain a new access token. More...
 
bool renewAccessToken (const QString &refreshToken)
 Issues a request to renew the access token. More...
 
OAuth2AccessToken accessToken () const
 Returns the OAuth2AccessToken. More...
 

Detailed Description

An object for performing OAuth2 authorizations for accessing Google APIs.

The basic steps to obtaining authorization are:

  1. Call buildAuthUrl() to obtain the authorization URL.
  2. Open the URL in a browser or QWebView to allow the user to log in and approve the authorization request.
  3. Call requestAccessToken() with the authorization code obtained from the previous step.
  4. Wait for the accessTokenReceived() signal.
  5. Call accessToken() to obtain the OAuth2AccessToken object.

When the access token expires, it can be refreshed by calling renewAccessToken().

For more information, see Using OAuth 2.0 to Access Google APIs.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ OAuth2Authenticator()

OAuth2Authenticator ( QNetworkAccessManager *  networkAccess,
const QString &  clientID,
const QString &  clientSecret,
QObject *  parent = NULL 
)

Constructs a new OAuth2Authenticator with the given attributes.

Parameters
networkAccessThe QNetworkAccessManager that will be used to perform the network requests.
clientIDThe client applications's assigned ID.
clientSecretThe client application's secret.
parentThe parent object.

◆ ~OAuth2Authenticator()

virtual ~OAuth2Authenticator ( )
virtual

Destructor.

Member Function Documentation

◆ accessToken()

OAuth2AccessToken accessToken ( ) const
inline

Returns the OAuth2AccessToken.

◆ accessTokenError

void accessTokenError ( const QString &  error)
signal

Emitted when there is an error obtaining an access token.

Parameters
errorThe error message.

◆ accessTokenReceived

void accessTokenReceived ( )
signal

Emitted when an access token has been received.

◆ buildAuthUrl()

QUrl buildAuthUrl ( const QStringList &  authScopes)

Constructs the authorization URL at which the user will be prompted to log in to their Google account and/or approve/deny an authorization request.

Parameters
authScopesThe list of scopes for which authorization is being requested.
Returns
The authorization URL.

◆ renewAccessToken()

bool renewAccessToken ( const QString &  refreshToken)

Issues a request to renew the access token.

This is an asynchronous operation; when the request is complete, either the accessTokenReceived() or accessTokenError() signal will be invoked.

Parameters
refreshTokenThe refresh token.
Returns
true if the request was successfully started, false otherwise.

◆ requestAccessToken()

bool requestAccessToken ( const QString &  authorizationCode)

Issues a request to obtain a new access token.

Parameters
authorizationCodeThe authorization code for the request. This is an asynchronous operation; when the request is complete, either the accessTokenReceived() or accessTokenError() signal will be invoked.

The documentation for this class was generated from the following file: