QOAuth1 Class

The QOAuth1 class provides an implementation of the OAuth 1 Protocol . 更多...

头: #include <QOAuth1>
qmake: QT += networkauth
Since: Qt 5.8
继承: QAbstractOAuth

该类在 Qt 5.8 引入。

公共类型

enum class SignatureMethod { Hmac_Sha1, Rsa_Sha1, PlainText }

公共函数

QOAuth1 (const QString & clientIdentifier , const QString & clientSharedSecret , QNetworkAccessManager * manager , QObject * parent = nullptr)
QOAuth1 (QNetworkAccessManager * manager , QObject * parent = nullptr)
QOAuth1 (QObject * parent = nullptr)
QPair<QString, QString> clientCredentials () const
QString clientSharedSecret () const
void setClientCredentials (const QPair<QString, QString> & clientCredentials )
void setClientCredentials (const QString & clientIdentifier , const QString & clientSharedSecret )
void setClientSharedSecret (const QString & clientSharedSecret )
void setSignatureMethod (QOAuth1::SignatureMethod value )
void setTemporaryCredentialsUrl (const QUrl & url )
void setTokenCredentials (const QPair<QString, QString> & tokenCredentials )
void setTokenCredentials (const QString & token , const QString & tokenSecret )
void setTokenCredentialsUrl (const QUrl & url )
void setTokenSecret (const QString & tokenSecret )
QOAuth1::SignatureMethod signatureMethod () const
QUrl temporaryCredentialsUrl () const
QPair<QString, QString> tokenCredentials () const
QUrl tokenCredentialsUrl () const
QString tokenSecret () const

重实现公共函数

virtual QNetworkReply * deleteResource (const QUrl & url , const QVariantMap & 参数 = QVariantMap()) override
virtual QNetworkReply * get (const QUrl & url , const QVariantMap & 参数 = QVariantMap()) override
virtual QNetworkReply * head (const QUrl & url , const QVariantMap & 参数 = QVariantMap()) override
virtual QNetworkReply * post (const QUrl & url , const QVariantMap & 参数 = QVariantMap()) override
virtual QNetworkReply * put (const QUrl & url , const QVariantMap & 参数 = QVariantMap()) override

公共槽

void continueGrantWithVerifier (const QString & verifier )
virtual void grant () override

保护函数

QNetworkReply * requestTemporaryCredentials (QNetworkAccessManager::Operation operation , const QUrl & url , const QVariantMap & 参数 = QVariantMap())
QNetworkReply * requestTokenCredentials (QNetworkAccessManager::Operation operation , const QUrl & url , const QPair<QString, QString> & temporaryToken , const QVariantMap & 参数 = QVariantMap())
void setup (QNetworkRequest * request , const QVariantMap & signingParameters , QNetworkAccessManager::Operation operation )
void setup (QNetworkRequest * request , const QVariantMap & signingParameters , const QByteArray & operationVerb )

静态保护成员

QByteArray generateAuthorizationHeader (const QVariantMap & oauthParams )
QByteArray nonce ()

详细描述

QOAuth1 provides a method for clients to access server resources on behalf of a resource owner (such as a different client or an end-user). It also provides a process for end-users to authorize third-party access to their server resources without sharing their credentials (typically, a username and password pair), using user-agent redirections.

QOAuth1 uses tokens to represent the authorization granted to the client by the resource owner. Typically, token credentials are issued by the server at the resource owner's request, after authenticating the resource owner's identity (usually using a username and password).

When making the temporary credentials request, the client authenticates using only the client credentials. When making the token request, the client authenticates using the client credentials as well as the temporary credentials. Once the client receives and stores the token credentials, it can proceed to access protected resources on behalf of the resource owner by making authenticated requests using the client credentials together with the token credentials received.

成员类型文档编制

enum class QOAuth1:: SignatureMethod

Indicates the signature method to be used to sign requests.

常量 描述
QOAuth1::SignatureMethod::Hmac_Sha1 0 HMAC-SHA1 signature method.
QOAuth1::SignatureMethod::Rsa_Sha1 1 RSA-SHA1 signature method (not supported).
QOAuth1::SignatureMethod::PlainText 2 PLAINTEXT signature method.

成员函数文档编制

QOAuth1:: QOAuth1 (const QString & clientIdentifier , const QString & clientSharedSecret , QNetworkAccessManager * manager , QObject * parent = nullptr)

Constructs a QOAuth1 object with parent object parent ,使用 manager to access the network. Also sets clientIdentifier and clientSharedSecret to sign the calls to the web server and identify the application.

QOAuth1:: QOAuth1 ( QNetworkAccessManager * manager , QObject * parent = nullptr)

Constructs a QOAuth1 object with parent object parent ,使用 manager to access the network.

QOAuth1:: QOAuth1 ( QObject * parent = nullptr)

Constructs a QOAuth1 object with parent object parent .

[slot] void QOAuth1:: continueGrantWithVerifier (const QString & verifier )

Continues the Redirection-Based Authorization flow using verifier . Call this function when using an Out-of-band reply handler to supply the verifier provided by the web server.

[override virtual slot] void QOAuth1:: grant ()

重实现: QAbstractOAuth::grant ().

Starts the Redirection-Based Authorization flow.

注意: For an out-of-band reply handler, a verifier string is received after the call to this function; pass that to continueGrantWithVerifier () to continue the grant process.

另请参阅 : The OAuth 1.0 Protocol: Redirection-Based Authorization

另请参阅 continueGrantWithVerifier ().

QPair < QString , QString > QOAuth1:: clientCredentials () const

Returns the pair of QString used to identify the application and sign requests to the web server.

另请参阅 setClientCredentials ().

QString QOAuth1:: clientSharedSecret () const

Returns the current shared secret used to sign requests to the web server.

另请参阅 setClientSharedSecret () 和 clientCredentials ().

[override virtual] QNetworkReply *QOAuth1:: deleteResource (const QUrl & url , const QVariantMap & 参数 = QVariantMap())

重实现: QAbstractOAuth::deleteResource (const QUrl &url, const QVariantMap ¶meters).

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

另请参阅 : Hypertext Transfer Protocol -- HTTP/1.1: DELETE

[static protected] QByteArray QOAuth1:: generateAuthorizationHeader (const QVariantMap & oauthParams )

Generates an authorization header using oauthParams .

另请参阅 : The OAuth 1.0 Protocol: Authorization Header

[override virtual] QNetworkReply *QOAuth1:: get (const QUrl & url , const QVariantMap & 参数 = QVariantMap())

重实现: QAbstractOAuth::get (const QUrl &url, const QVariantMap ¶meters).

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

另请参阅 : Hypertext Transfer Protocol -- HTTP/1.1: GET

重实现: QAbstractOAuth::head (const QUrl &url, const QVariantMap ¶meters).

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

另请参阅 : Hypertext Transfer Protocol -- HTTP/1.1: HEAD

[static protected] QByteArray QOAuth1:: nonce ()

Generates a nonce.

另请参阅 : The OAuth 1.0 Protocol: Nonce and Timestamp

[override virtual] QNetworkReply *QOAuth1:: post (const QUrl & url , const QVariantMap & 参数 = QVariantMap())

重实现: QAbstractOAuth::post (const QUrl &url, const QVariantMap ¶meters).

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

另请参阅 : Hypertext Transfer Protocol -- HTTP/1.1: POST

[override virtual] QNetworkReply *QOAuth1:: put (const QUrl & url , const QVariantMap & 参数 = QVariantMap())

重实现: QAbstractOAuth::put (const QUrl &url, const QVariantMap ¶meters).

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

另请参阅 : Hypertext Transfer Protocol -- HTTP/1.1: PUT

[protected] QNetworkReply *QOAuth1:: requestTemporaryCredentials ( QNetworkAccessManager::Operation operation , const QUrl & url , const QVariantMap & 参数 = QVariantMap())

Starts the a request for temporary credentials using the request method operation . The request URL is url 参数 shall encoded and sent during the request.

另请参阅 : The OAuth 1.0 Protocol: Temporary Credentials

[protected] QNetworkReply *QOAuth1:: requestTokenCredentials ( QNetworkAccessManager::Operation operation , const QUrl & url , const QPair < QString , QString > & temporaryToken , const QVariantMap & 参数 = QVariantMap())

Starts a request for token credentials using the request method operation . The request URL is url 参数 shall be encoded and sent during the request. The temporaryToken pair of string is used to identify and sign the request.

另请参阅 : The OAuth 1.0 Protocol: Token Credentials

void QOAuth1:: setClientCredentials (const QPair < QString , QString > & clientCredentials )

设置 clientCredentials as the pair of QString used to identify the application and sign requests to the web server.

另请参阅 clientCredentials ().

void QOAuth1:: setClientCredentials (const QString & clientIdentifier , const QString & clientSharedSecret )

设置 clientIdentifier and clientSharedSecret as the pair of QString used to identify the application and sign requests to the web server. clientIdentifier identifies the application and clientSharedSecret is used to sign requests.

另请参阅 clientCredentials ().

void QOAuth1:: setClientSharedSecret (const QString & clientSharedSecret )

设置 clientSharedSecret as the string used to sign the requests to the web server.

另请参阅 clientSharedSecret () 和 setClientCredentials ().

void QOAuth1:: setSignatureMethod ( QOAuth1::SignatureMethod value )

设置 value as the method used to sign requests to the web server.

另请参阅 signatureMethod ().

void QOAuth1:: setTemporaryCredentialsUrl (const QUrl & url )

设置 url as the URL to request temporary credentials to start the authentication process.

另请参阅 temporaryCredentialsUrl ().

void QOAuth1:: setTokenCredentials (const QPair < QString , QString > & tokenCredentials )

设置 tokenCredentials as the pair of QString used to identify and sign authenticated requests to the web server.

另请参阅 tokenCredentials ().

void QOAuth1:: setTokenCredentials (const QString & token , const QString & tokenSecret )

设置 token and tokenSecret as the pair of QString used to identify and sign authenticated requests to the web server. Once the client receives and stores the token credentials, it can proceed to access protected resources on behalf of the resource owner by making authenticated requests using the client credentials together with the token credentials received.

另请参阅 tokenCredentials ().

void QOAuth1:: setTokenCredentialsUrl (const QUrl & url )

设置 url as the URL to request the token credentials to continue the authentication process.

另请参阅 tokenCredentialsUrl ().

void QOAuth1:: setTokenSecret (const QString & tokenSecret )

设置 tokenSecret as the current token secret used to sign authenticated calls to the web server.

另请参阅 tokenSecret () 和 setTokenCredentials ().

[protected] void QOAuth1:: setup ( QNetworkRequest * request , const QVariantMap & signingParameters , QNetworkAccessManager::Operation operation )

Signs the request 使用 signingParameters and operation .

这是重载函数。

[protected] void QOAuth1:: setup ( QNetworkRequest * request , const QVariantMap & signingParameters , const QByteArray & operationVerb )

Signs the request 使用 signingParameters and operationVerb .

这是重载函数。

该函数在 Qt 5.13 引入。

QOAuth1::SignatureMethod QOAuth1:: signatureMethod () const

Returns the method used to sign the request to the web server.

另请参阅 setSignatureMethod ().

QUrl QOAuth1:: temporaryCredentialsUrl () const

Returns the url used to request temporary credentials to start the authentication process.

另请参阅 setTemporaryCredentialsUrl ().

QPair < QString , QString > QOAuth1:: tokenCredentials () const

Returns the pair of QString used to identify and sign authenticated requests to the web server.

另请参阅 setTokenCredentials ().

QUrl QOAuth1:: tokenCredentialsUrl () const

Returns the url used to request token credentials to continue the authentication process.

另请参阅 setTokenCredentialsUrl ().

QString QOAuth1:: tokenSecret () const

Returns the current token secret used to sign authenticated requests to the web server.

另请参阅 setTokenSecret () 和 tokenCredentials ().