QAbstractOAuth Class
The QAbstractOAuth class is the base of all implementations of OAuth authentication methods. More...
| Header: | #include <QAbstractOAuth> |
| qmake: | QT += networkauth |
| Since: | Qt 5.8 |
| Inherits: | QObject |
| Inherited By: |
This class was introduced in Qt 5.8.
Public Types
| enum class | ContentType { WwwFormUrlEncoded, Json } |
| enum class | Error { NoError, NetworkError, ServerError, OAuthTokenNotFoundError, OAuthTokenSecretNotFoundError, OAuthCallbackNotVerified } |
| enum class | Stage { RequestingTemporaryCredentials, RequestingAuthorization, RequestingAccessToken, RefreshingAccessToken } |
| enum class | Status { NotAuthenticated, TemporaryCredentialsReceived, Granted, RefreshingToken } |
Properties
- authorizationUrl : QUrl
- contentType : QAbstractOAuth::ContentType
- extraTokens : const QVariantMap
- status : const Status
Public Functions
| QUrl | authorizationUrl() const |
| QString | clientIdentifier() const |
| QAbstractOAuth::ContentType | contentType() const |
| QVariantMap | extraTokens() const |
| void | setAuthorizationUrl(const QUrl &url) |
| void | setClientIdentifier(const QString &clientIdentifier) |
| void | setContentType(QAbstractOAuth::ContentType contentType) |
| void | setToken(const QString &token) |
| QAbstractOAuth::Status | status() const |
| QString | token() const |
Signals
| void | authorizationUrlChanged(const QUrl &url) |
| void | clientIdentifierChanged(const QString &clientIdentifier) |
| void | contentTypeChanged(QAbstractOAuth::ContentType contentType) |
| void | extraTokensChanged(const QVariantMap &tokens) |
| void | statusChanged(QAbstractOAuth::Status status) |
| void | tokenChanged(const QString &token) |
Detailed Description
The class defines the basic interface of the OAuth authentication classes. By inheriting this class, you can create custom authentication methods for different web services.
It also contains some functions to ease the process of implementing different authentication flows.
Member Type Documentation
enum class QAbstractOAuth::ContentType
Indicates the MIME Content-Type of the POST methods in authenticated calls.
| Constant | Value | Description |
|---|---|---|
QAbstractOAuth::ContentType::WwwFormUrlEncoded | 0 | Uses application/x-www-form-urlencoded format. |
QAbstractOAuth::ContentType::Json | 1 | Uses application/json format. |
enum class QAbstractOAuth::Error
Indicates the latest received error.
| Constant | Value | Description |
|---|---|---|
QAbstractOAuth::Error::NoError | 0 | No error has ocurred. |
QAbstractOAuth::Error::NetworkError | 1 | Failed to connect to the server. |
QAbstractOAuth::Error::ServerError | 2 | The server answered the request with an error. |
QAbstractOAuth::Error::OAuthTokenNotFoundError | 3 | The server's response to a token request provided no token identifier. |
QAbstractOAuth::Error::OAuthTokenSecretNotFoundError | 4 | The server's response to a token request provided no token secret. |
QAbstractOAuth::Error::OAuthCallbackNotVerified | 5 | The authorization server has not verified the supplied callback URI in the request. This usually happens when the provided callback does not match with the callback supplied during client registration. |
enum class QAbstractOAuth::Stage
Identifies an authentication stage. It's passed to a modifyParametersFunction so that it can make different changes to parameters at each call to it during the process of authentication.
| Constant | Value | Description |
|---|---|---|
QAbstractOAuth::Stage::RequestingTemporaryCredentials | 0 | Preparing the temporary credentials request. |
QAbstractOAuth::Stage::RequestingAuthorization | 1 | Preparing the authorization grant URL. |
QAbstractOAuth::Stage::RequestingAccessToken | 2 | Preparing the token request. |
QAbstractOAuth::Stage::RefreshingAccessToken | 3 | Preparing the access token refresh. |
enum class QAbstractOAuth::Status
Indicates the current authentication status.
| Constant | Value | Description |
|---|---|---|
QAbstractOAuth::Status::NotAuthenticated | 0 | No token has been retrieved. |
QAbstractOAuth::Status::TemporaryCredentialsReceived | 1 | Temporary credentials have been received, this status is used in some OAuth authetication methods. |
QAbstractOAuth::Status::Granted | 2 | Token credentials have been received and authenticated calls are allowed. |
QAbstractOAuth::Status::RefreshingToken | 3 | New token credentials have been requested. |
Property Documentation
authorizationUrl : QUrl
This property holds the URL used to request the Resource Owner Authorization as described in: The OAuth 1.0 Protocol: Resource Owner Authorization
Access functions:
| QUrl | authorizationUrl() const |
| void | setAuthorizationUrl(const QUrl &url) |
Notifier signal:
| void | authorizationUrlChanged(const QUrl &url) |
contentType : QAbstractOAuth::ContentType
This property holds the Content-Type to use when sending authorization parameters.
This property controls how parameters are formatted when sent with a POST request. A suitable header is also added.
Access functions:
| QAbstractOAuth::ContentType | contentType() const |
| void | setContentType(QAbstractOAuth::ContentType contentType) |
Notifier signal:
| void | contentTypeChanged(QAbstractOAuth::ContentType contentType) |
extraTokens : const QVariantMap
This property holds the extra tokens received from the server.
Access functions:
| QVariantMap | extraTokens() const |
Notifier signal:
| void | extraTokensChanged(const QVariantMap &tokens) |
status : const Status
This property holds the current authentication status.
Access functions:
| QAbstractOAuth::Status | status() const |
Notifier signal:
| void | statusChanged(QAbstractOAuth::Status status) |