QOAuth1Signature#

Implements OAuth 1 signature methods. More

Synopsis#

Functions#

Static functions#

  • def plainText (clientSharedSecret, tokenSecret)

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

OAuth-authenticated requests can have two sets of credentials: those passed via the “oauth_consumer_key” parameter and those in the “oauth_token” parameter. In order for the server to verify the authenticity of the request and prevent unauthorized access, the client needs to prove that it is the rightful owner of the credentials. This is accomplished using the shared-secret (or RSA key) part of each set of credentials.

OAuth specifies three methods for the client to establish its rightful ownership of the credentials: “HMAC-SHA1”, “RSA-SHA1”, and “PLAINTEXT”. Each generates a “signature” with which the request is “signed”; the first two use a digest of the data signed in generating this, though the last does not. The “RSA-SHA1” method is not supported here; it would use an RSA key rather than the shared-secret associated with the client credentials.

class PySide6.QtNetworkAuth.QOAuth1Signature(other)#

PySide6.QtNetworkAuth.QOAuth1Signature([url=QUrl()[, method=QOAuth1Signature.HttpRequestMethod.Post[, parameters={}]]])

PySide6.QtNetworkAuth.QOAuth1Signature(url, clientSharedKey, tokenSecret[, method=QOAuth1Signature.HttpRequestMethod.Post[, parameters={}]])

Parameters:

Creates a copy of other.

Creates a QOAuth1Signature using

  • url as the target address

  • method as the HTTP method used to send the request

  • and the given user parameters to augment the request.

Creates a QOAuth1Signature using

  • url as the target address

  • clientSharedKey as the user token used to verify the signature

  • tokenSecret as the negotiated token used to verify the signature

  • method as the HTTP method used to send the request

  • and the given user parameters to augment the request.

PySide6.QtNetworkAuth.QOAuth1Signature.HttpRequestMethod#

Indicates the HTTP request method.

Constant

Description

QOAuth1Signature.HttpRequestMethod.Head

HEAD method.

QOAuth1Signature.HttpRequestMethod.Get

GET method.

QOAuth1Signature.HttpRequestMethod.Put

PUT method.

QOAuth1Signature.HttpRequestMethod.Post

POST method.

QOAuth1Signature.HttpRequestMethod.Delete

DELETE method.

QOAuth1Signature.HttpRequestMethod.Custom

Identifies a custom method.

QOAuth1Signature.HttpRequestMethod.Unknown

Method not set.

PySide6.QtNetworkAuth.QOAuth1Signature.addRequestBody(body)#
Parameters:

bodyPySide6.QtCore.QUrlQuery

Adds the request body to the signature. When a POST request body contains arguments they should be included in the signed data.

PySide6.QtNetworkAuth.QOAuth1Signature.clientSharedKey()#
Return type:

str

Returns the user secret used to generate the signature.

PySide6.QtNetworkAuth.QOAuth1Signature.customMethodString()#
Return type:

PySide6.QtCore.QByteArray

Returns the custom method string.

PySide6.QtNetworkAuth.QOAuth1Signature.hmacSha1()#
Return type:

PySide6.QtCore.QByteArray

Generates the HMAC-SHA1 signature using the client shared secret and, where available, token secret.

PySide6.QtNetworkAuth.QOAuth1Signature.httpRequestMethod()#
Return type:

HttpRequestMethod

Returns the request method.

PySide6.QtNetworkAuth.QOAuth1Signature.insert(key, value)#
Parameters:
  • key – str

  • value – object

Inserts a new pair key, value into the signature. When a POST request body contains arguments they should be included in the signed data.

PySide6.QtNetworkAuth.QOAuth1Signature.keys()#
Return type:

.list of QString

Retrieves the list of keys of parameters included in the signed data.

PySide6.QtNetworkAuth.QOAuth1Signature.parameters()#
Return type:

.QMultiMapQString,QVariant

Returns the parameters.

See also

setParameters()

PySide6.QtNetworkAuth.QOAuth1Signature.plainText()#
Return type:

PySide6.QtCore.QByteArray

Generates the PLAINTEXT signature.

static PySide6.QtNetworkAuth.QOAuth1Signature.plainText(clientSharedSecret, tokenSecret)
Parameters:
  • clientSharedSecret – str

  • tokenSecret – str

Return type:

PySide6.QtCore.QByteArray

Generates a PLAINTEXT signature from the client secret clientSharedKey and the token secret tokenSecret.

PySide6.QtNetworkAuth.QOAuth1Signature.rsaSha1()#
Return type:

PySide6.QtCore.QByteArray

Generates the RSA-SHA1 signature.

Note

Currently this method is not supported.

PySide6.QtNetworkAuth.QOAuth1Signature.setClientSharedKey(secret)#
Parameters:

secret – str

Sets secret as the user secret used to generate the signature.

PySide6.QtNetworkAuth.QOAuth1Signature.setCustomMethodString(verb)#
Parameters:

verbPySide6.QtCore.QByteArray

Sets a custom request method. Will set the httpRequestMethod to Custom and store the verb to use it for the generation of the signature.

Note

Using this method is required when working with custom verbs. Setting only the request method will fail, as the signure needs to know the actual verb.

See also

customMethodString() setHttpRequestMethod() HttpRequestMethod

PySide6.QtNetworkAuth.QOAuth1Signature.setHttpRequestMethod(method)#
Parameters:

methodHttpRequestMethod

Sets the request method.

PySide6.QtNetworkAuth.QOAuth1Signature.setParameters(parameters)#
Parameters:

parameters – .QMultiMapQString,QVariant

Sets the parameters.

See also

parameters()

PySide6.QtNetworkAuth.QOAuth1Signature.setTokenSecret(secret)#
Parameters:

secret – str

Sets secret as the negotiated secret used to generate the signature.

See also

tokenSecret()

PySide6.QtNetworkAuth.QOAuth1Signature.setUrl(url)#
Parameters:

urlPySide6.QtCore.QUrl

Sets the URL to url.

See also

url()

PySide6.QtNetworkAuth.QOAuth1Signature.swap(other)#
Parameters:

otherPySide6.QtNetworkAuth.QOAuth1Signature

Swaps signature other with this signature. This operation is very fast and never fails.

PySide6.QtNetworkAuth.QOAuth1Signature.take(key)#
Parameters:

key – str

Return type:

object

Removes key and any associated value from the signed data.

PySide6.QtNetworkAuth.QOAuth1Signature.tokenSecret()#
Return type:

str

Returns the negotiated secret used to generate the signature.

See also

setTokenSecret()

PySide6.QtNetworkAuth.QOAuth1Signature.url()#
Return type:

PySide6.QtCore.QUrl

Returns the URL.

See also

setUrl()

PySide6.QtNetworkAuth.QOAuth1Signature.value(key[, defaultValue=None])#
Parameters:
  • key – str

  • defaultValue – object

Return type:

object

Returns the value associated with key, if present in the signed data, otherwise defaultValue.