IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QAbstractOAuth2 Class

The QAbstractOAuth2 class is the base of all implementations of OAuth 2 authentication methods.

This class was introduced in Qt 5.8.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QAbstractOAuth2 Class

  • Header: QAbstractOAuth2

  • Since: Qt 5.8

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS NetworkAuth)

    target_link_libraries(mytarget PRIVATE Qt6::NetworkAuth)

  • qmake: QT += networkauth

  • Inherits: QAbstractOAuth

  • Inherited By: QOAuth2AuthorizationCodeFlow

  • Group: QAbstractOAuth2 is part of oauth

Detailed Description

The class defines the basic interface of the OAuth 2 authentication classes. By inheriting this class, you can create custom authentication methods using the OAuth 2 standard for different web services.

A description of how OAuth 2 works can be found in: The OAuth 2.0 Authorization Framework

Property Documentation

 

clientIdentifierSharedKey : QString

This property holds the client shared key used as a password if the server requires authentication to request the token.

Access functions:

  • clientIdentifierSharedKey() const

  • void setClientIdentifierSharedKey(const &clientIdentifierSharedKey)

Notifier signal:

  • void clientIdentifierSharedKeyChanged(const &clientIdentifierSharedKey)

[read-only] expiration : const QDateTime

This property holds the expiration time of the current access token.

Access functions:

  • expirationAt() const

Notifier signal:

  • void expirationAtChanged(const &expiration)

scope : QString

This property holds the desired scope which defines the permissions requested by the client.

Access functions:

  • scope() const

  • void setScope(const &scope)

Notifier signal:

  • void scopeChanged(const &scope)

state : QString

This property holds the string sent to the server during authentication. The state is used to identify and validate the request when the callback is received.

Access functions:

  • state() const

  • void setState(const &state)

Notifier signal:

  • void stateChanged(const &state)

userAgent : QString

This property holds the User-Agent header used to create the network requests.

The default value is "QtOAuth/1.0 (+https://www.qt.io)".

Access functions:

  • userAgent() const

  • void setUserAgent(const &userAgent)

Notifier signal:

  • void userAgentChanged(const &userAgent)

Member Function Documentation

 

[explicit] QAbstractOAuth2::QAbstractOAuth2(QObject *parent = nullptr)

Constructs a QAbstractOAuth2 object using parent as parent.

[explicit] QAbstractOAuth2::QAbstractOAuth2(QNetworkAccessManager *manager, QObject *parent = nullptr)

Constructs a QAbstractOAuth2 object using parent as parent and sets manager as the network access manager.

[virtual] QAbstractOAuth2::~QAbstractOAuth2()

Destroys the QAbstractOAuth2 instance.

void QAbstractOAuth2::authorizationCallbackReceived(const QVariantMap &data)

Signal emitted when the reply server receives the authorization callback from the server: data contains the values received from the server.

[virtual] QUrl QAbstractOAuth2::createAuthenticatedUrl(const QUrl &url, const QVariantMap &parameters = QVariantMap())

The returned URL is based on url, combining it with the given parameters and the access token.

[override virtual] QNetworkReply *QAbstractOAuth2::deleteResource(const QUrl &url, const QVariantMap &parameters = QVariantMap())

Reimplements: QAbstractOAuth::deleteResource(const QUrl &url, const QVariantMap &parameters).

Sends an authenticated DELETE request and returns a new QNetworkReply. The url and parameters are used to create the request.

See also: Hypertext Transfer Protocol – HTTP/1.1: DELETE

void QAbstractOAuth2::error(const QString &error, const QString &errorDescription, const QUrl &uri)

Signal emitted when the server responds to the request with an error: error is the name of the error; errorDescription describes the error and uri is an optional URI containing more information about the error.

[override virtual] QNetworkReply *QAbstractOAuth2::get(const QUrl &url, const QVariantMap &parameters = QVariantMap())

Reimplements: QAbstractOAuth::get(const QUrl &url, const QVariantMap &parameters).

Sends an authenticated GET request and returns a new QNetworkReply. The url and parameters are used to create the request.

See also: Hypertext Transfer Protocol – HTTP/1.1: GET

[override virtual] QNetworkReply *QAbstractOAuth2::head(const QUrl &url, const QVariantMap &parameters = QVariantMap())

Sends an authenticated HEAD request and returns a new QNetworkReply. The url and parameters are used to create the request.

See also: Hypertext Transfer Protocol – HTTP/1.1: HEAD

[override virtual] QNetworkReply *QAbstractOAuth2::post(const QUrl &url, const QVariantMap &parameters = QVariantMap())

Reimplements: QAbstractOAuth::post(const QUrl &url, const QVariantMap &parameters).

Sends an authenticated POST request and returns a new QNetworkReply. The url and parameters are used to create the request.

See also: Hypertext Transfer Protocol – HTTP/1.1: POST

[virtual, since 5.10] QNetworkReply *QAbstractOAuth2::post(const QUrl &url, const QByteArray &data)

This is an overloaded function.

Sends an authenticated POST request and returns a new QNetworkReply. The url and data are used to create the request.

{Hypertext Transfer Protocol – HTTP/1.1: POST}

This function was introduced in Qt 5.10.

See Also

[virtual, since 5.10] QNetworkReply *QAbstractOAuth2::post(const QUrl &url, QHttpMultiPart *multiPart)

This is an overloaded function.

Sends an authenticated POST request and returns a new QNetworkReply. The url and multiPart are used to create the request.

{Hypertext Transfer Protocol – HTTP/1.1: POST}

This function was introduced in Qt 5.10.

See Also

[override virtual] void QAbstractOAuth2::prepareRequest(QNetworkRequest *request, const QByteArray &verb, const QByteArray &body = QByteArray())

[override virtual] QNetworkReply *QAbstractOAuth2::put(const QUrl &url, const QVariantMap &parameters = QVariantMap())

Reimplements: QAbstractOAuth::put(const QUrl &url, const QVariantMap &parameters).

Sends an authenticated PUT request and returns a new QNetworkReply. The url and parameters are used to create the request.

See also: Hypertext Transfer Protocol – HTTP/1.1: PUT

[virtual, since 5.10] QNetworkReply *QAbstractOAuth2::put(const QUrl &url, const QByteArray &data)

This is an overloaded function.

Sends an authenticated PUT request and returns a new QNetworkReply. The url and data are used to create the request.

{Hypertext Transfer Protocol – HTTP/1.1: PUT}

This function was introduced in Qt 5.10.

See Also

[virtual, since 5.10] QNetworkReply *QAbstractOAuth2::put(const QUrl &url, QHttpMultiPart *multiPart)

This is an overloaded function.

Sends an authenticated PUT request and returns a new QNetworkReply. The url and multiPart are used to create the request.

{Hypertext Transfer Protocol – HTTP/1.1: PUT}

This function was introduced in Qt 5.10.

See Also

QString QAbstractOAuth2::refreshToken() const

Gets the current refresh token.

Refresh tokens usually have longer lifespans than access tokens, so it makes sense to save them for later use.

Returns the current refresh token or an empty string, if there is no refresh token available.

Getter function for property refreshToken.

See Also

See also setRefreshToken()

QString QAbstractOAuth2::responseType() const

Returns the response_type used.

void QAbstractOAuth2::setRefreshToken(const QString &refreshToken)

Sets the new refresh token refreshToken to be used.

A custom refresh token can be used to refresh the access token via this method and then the access token can be refreshed via QOAuth2AuthorizationCodeFlow::refreshAccessToken().

Setter function for property refreshToken.

See Also

See also refreshToken()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+