An object for performing OAuth2 authorizations for accessing Google APIs.
More...
#include <OAuth2Authenticator.h++>
An object for performing OAuth2 authorizations for accessing Google APIs.
The basic steps to obtaining authorization are:
-
Call buildAuthUrl() to obtain the authorization URL.
-
Open the URL in a browser or QWebView to allow the user to log in and approve the authorization request.
-
Call requestAccessToken() with the authorization code obtained from the previous step.
-
Wait for the accessTokenReceived() signal.
-
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
◆ OAuth2Authenticator()
| OAuth2Authenticator |
( |
QNetworkAccessManager * |
networkAccess, |
|
|
const QString & |
clientID, |
|
|
const QString & |
clientSecret, |
|
|
QObject * |
parent = NULL |
|
) |
| |
Constructs a new OAuth2Authenticator with the given attributes.
- Parameters
-
| networkAccess | The QNetworkAccessManager that will be used to perform the network requests. |
| clientID | The client applications's assigned ID. |
| clientSecret | The client application's secret. |
| parent | The parent object. |
◆ ~OAuth2Authenticator()
◆ accessToken()
◆ accessTokenError
| void accessTokenError |
( |
const QString & |
error | ) |
|
|
signal |
Emitted when there is an error obtaining an access token.
- Parameters
-
◆ 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
-
| authScopes | The 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
-
| refreshToken | The 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
-
| authorizationCode | The 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: