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:

QAbstractOAuth2 and QOAuth1

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

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.

ConstantValueDescription
QAbstractOAuth::ContentType::WwwFormUrlEncoded0Uses application/x-www-form-urlencoded format.
QAbstractOAuth::ContentType::Json1Uses application/json format.

enum class QAbstractOAuth::Error

Indicates the latest received error.

ConstantValueDescription
QAbstractOAuth::Error::NoError0No error has ocurred.
QAbstractOAuth::Error::NetworkError1Failed to connect to the server.
QAbstractOAuth::Error::ServerError2The server answered the request with an error.
QAbstractOAuth::Error::OAuthTokenNotFoundError3The server's response to a token request provided no token identifier.
QAbstractOAuth::Error::OAuthTokenSecretNotFoundError4The server's response to a token request provided no token secret.
QAbstractOAuth::Error::OAuthCallbackNotVerified5The 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.

ConstantValueDescription
QAbstractOAuth::Stage::RequestingTemporaryCredentials0Preparing the temporary credentials request.
QAbstractOAuth::Stage::RequestingAuthorization1Preparing the authorization grant URL.
QAbstractOAuth::Stage::RequestingAccessToken2Preparing the token request.
QAbstractOAuth::Stage::RefreshingAccessToken3Preparing the access token refresh.

enum class QAbstractOAuth::Status

Indicates the current authentication status.

ConstantValueDescription
QAbstractOAuth::Status::NotAuthenticated0No token has been retrieved.
QAbstractOAuth::Status::TemporaryCredentialsReceived1Temporary credentials have been received, this status is used in some OAuth authetication methods.
QAbstractOAuth::Status::Granted2Token credentials have been received and authenticated calls are allowed.
QAbstractOAuth::Status::RefreshingToken3New 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)