QAbstractOAuth¶
The QAbstractOAuth
class is the base of all implementations of OAuth authentication methods. More…
Inherited by: QOAuth1, QAbstractOAuth2, QOAuth2AuthorizationCodeFlow
Synopsis¶
Functions¶
def
authorizationUrl
()def
callback
()def
clientIdentifier
()def
contentType
()def
extraTokens
()def
networkAccessManager
()def
replyHandler
()def
setAuthorizationUrl
(url)def
setClientIdentifier
(clientIdentifier)def
setContentType
(contentType)def
setModifyParametersFunction
(modifyParametersFunction)def
setNetworkAccessManager
(networkAccessManager)def
setReplyHandler
(handler)def
setStatus
(status)def
setToken
(token)def
status
()def
token
()
Virtual functions¶
def
deleteResource
(url[, parameters=QVariantMap()])def
get
(url[, parameters=QVariantMap()])def
grant
()def
head
(url[, parameters=QVariantMap()])def
post
(url[, parameters=QVariantMap()])def
prepareRequest
(request, verb[, body=QByteArray()])def
put
(url[, parameters=QVariantMap()])def
resourceOwnerAuthorization
(url, parameters)
Signals¶
def
authorizationUrlChanged
(url)def
authorizeWithBrowser
(url)def
clientIdentifierChanged
(clientIdentifier)def
contentTypeChanged
(contentType)def
extraTokensChanged
(tokens)def
finished
(reply)def
granted
()def
replyDataReceived
(data)def
requestFailed
(error)def
statusChanged
(status)def
tokenChanged
(token)
Static functions¶
def
generateRandomString
(length)
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.
- class PySide6.QtNetworkAuth.QAbstractOAuth¶
- PySide6.QtNetworkAuth.QAbstractOAuth.Status¶
Indicates the current authentication status.
Constant
Description
QAbstractOAuth.Status.NotAuthenticated
No token has been retrieved.
QAbstractOAuth.Status.TemporaryCredentialsReceived
Temporary credentials have been received, this status is used in some OAuth authetication methods.
QAbstractOAuth.Status.Granted
Token credentials have been received and authenticated calls are allowed.
QAbstractOAuth.Status.RefreshingToken
New token credentials have been requested.
- PySide6.QtNetworkAuth.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
Description
QAbstractOAuth.Stage.RequestingTemporaryCredentials
Preparing the temporary credentials request.
QAbstractOAuth.Stage.RequestingAuthorization
Preparing the authorization grant URL.
QAbstractOAuth.Stage.RequestingAccessToken
Preparing the token request.
QAbstractOAuth.Stage.RefreshingAccessToken
Preparing the access token refresh.
- PySide6.QtNetworkAuth.QAbstractOAuth.Error¶
Indicates the latest received error.
Constant
Description
QAbstractOAuth.Error.NoError
No error has ocurred.
QAbstractOAuth.Error.NetworkError
Failed to connect to the server.
QAbstractOAuth.Error.ServerError
The server answered the request with an error.
QAbstractOAuth.Error.OAuthTokenNotFoundError
The server’s response to a token request provided no token identifier.
QAbstractOAuth.Error.OAuthTokenSecretNotFoundError
The server’s response to a token request provided no token secret.
QAbstractOAuth.Error.OAuthCallbackNotVerified
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.
- PySide6.QtNetworkAuth.QAbstractOAuth.ContentType¶
Indicates the MIME Content-Type of the POST methods in authenticated calls.
Constant
Description
QAbstractOAuth.ContentType.WwwFormUrlEncoded
Uses application/x-www-form-urlencoded format.
QAbstractOAuth.ContentType.Json
Uses application/json format.
- PySide6.QtNetworkAuth.QAbstractOAuth.authorizationUrl()¶
- Return type
This property holds This property holds the URL used to request the Resource Owner Authorization as described in: The OAuth 1.0 Protocol: Resource Owner Authorization .
- PySide6.QtNetworkAuth.QAbstractOAuth.authorizationUrlChanged(url)¶
- Parameters
url –
PySide6.QtCore.QUrl
- PySide6.QtNetworkAuth.QAbstractOAuth.authorizeWithBrowser(url)¶
- Parameters
url –
PySide6.QtCore.QUrl
- PySide6.QtNetworkAuth.QAbstractOAuth.callback()¶
- Return type
str
Returns the current callback string corresponding to the current reply handler. The returned string is the string sent to the server to specify the callback URI, or the word identifying the alternative method in headless devices.
See also
- PySide6.QtNetworkAuth.QAbstractOAuth.clientIdentifier()¶
- Return type
str
- PySide6.QtNetworkAuth.QAbstractOAuth.clientIdentifierChanged(clientIdentifier)¶
- Parameters
clientIdentifier – str
- PySide6.QtNetworkAuth.QAbstractOAuth.contentType()¶
- Return type
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.
- PySide6.QtNetworkAuth.QAbstractOAuth.contentTypeChanged(contentType)¶
- Parameters
contentType –
ContentType
- PySide6.QtNetworkAuth.QAbstractOAuth.deleteResource(url[, parameters=QVariantMap()])¶
- Parameters
url –
PySide6.QtCore.QUrl
parameters –
- Return type
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
- PySide6.QtNetworkAuth.QAbstractOAuth.extraTokens()¶
- Return type
This property holds This property holds the extra tokens received from the server..
- PySide6.QtNetworkAuth.QAbstractOAuth.extraTokensChanged(tokens)¶
- Parameters
tokens –
- PySide6.QtNetworkAuth.QAbstractOAuth.finished(reply)¶
- Parameters
reply –
PySide6.QtNetwork.QNetworkReply
- static PySide6.QtNetworkAuth.QAbstractOAuth.generateRandomString(length)¶
- Parameters
length –
quint8
- Return type
Generates a random string which could be used as state or nonce. The parameter length
determines the size of the generated string.
See also: The OAuth 1.0 Protocol: Nonce and Timestamp .
- PySide6.QtNetworkAuth.QAbstractOAuth.get(url[, parameters=QVariantMap()])¶
- Parameters
url –
PySide6.QtCore.QUrl
parameters –
- Return type
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
- PySide6.QtNetworkAuth.QAbstractOAuth.grant()¶
Override this function to implement the corresponding authentication flow in the subclasses. Client code calls this function to start the authentication workflow. This may require user interaction: for example, asking the user’s authorization via a web browser. When the authentication succeeds, it should emit granted()
; this gives notice that credentials are ready to be used in authenticated calls.
- PySide6.QtNetworkAuth.QAbstractOAuth.granted()¶
- PySide6.QtNetworkAuth.QAbstractOAuth.head(url[, parameters=QVariantMap()])¶
- Parameters
url –
PySide6.QtCore.QUrl
parameters –
- Return type
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
- PySide6.QtNetworkAuth.QAbstractOAuth.networkAccessManager()¶
- Return type
Returns the current network access manager used to send the requests to the server during authentication flows or to make authentication calls.
See also
setNetworkAccessManager()
QNetworkAccessManager
- PySide6.QtNetworkAuth.QAbstractOAuth.post(url[, parameters=QVariantMap()])¶
- Parameters
url –
PySide6.QtCore.QUrl
parameters –
- Return type
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
- PySide6.QtNetworkAuth.QAbstractOAuth.prepareRequest(request, verb[, body=QByteArray()])¶
- Parameters
request –
PySide6.QtNetwork.QNetworkRequest
verb –
PySide6.QtCore.QByteArray
body –
PySide6.QtCore.QByteArray
Authorizes the given request
by adding a header and body
to it required for authenticated requests.
The verb
must be a valid HTTP verb and the same as the one that will be used to send the request
.
- PySide6.QtNetworkAuth.QAbstractOAuth.put(url[, parameters=QVariantMap()])¶
- Parameters
url –
PySide6.QtCore.QUrl
parameters –
- Return type
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
- PySide6.QtNetworkAuth.QAbstractOAuth.replyDataReceived(data)¶
- Parameters
data –
PySide6.QtCore.QByteArray
- PySide6.QtNetworkAuth.QAbstractOAuth.replyHandler()¶
- Return type
Returns the reply handler currently in use.
- PySide6.QtNetworkAuth.QAbstractOAuth.resourceOwnerAuthorization(url, parameters)¶
- Parameters
url –
PySide6.QtCore.QUrl
parameters –
Builds the resource owner authorization URL to be used in the web browser: url
is used as the base URL and the query is created using parameters
. When the URL is ready, the authorizeWithBrowser()
signal will be emitted with the generated URL.
See also
- PySide6.QtNetworkAuth.QAbstractOAuth.setAuthorizationUrl(url)¶
- Parameters
url –
PySide6.QtCore.QUrl
This property holds This property holds the URL used to request the Resource Owner Authorization as described in: The OAuth 1.0 Protocol: Resource Owner Authorization .
- PySide6.QtNetworkAuth.QAbstractOAuth.setClientIdentifier(clientIdentifier)¶
- Parameters
clientIdentifier – str
- PySide6.QtNetworkAuth.QAbstractOAuth.setContentType(contentType)¶
- Parameters
contentType –
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.
- PySide6.QtNetworkAuth.QAbstractOAuth.setModifyParametersFunction(modifyParametersFunction)¶
- Parameters
modifyParametersFunction – object
- PySide6.QtNetworkAuth.QAbstractOAuth.setNetworkAccessManager(networkAccessManager)¶
- Parameters
networkAccessManager –
PySide6.QtNetwork.QNetworkAccessManager
Sets the network manager to networkAccessManager
. QAbstractOAuth
does not take ownership of networkAccessManager
. If no custom network access manager is set, an internal network access manager is used. This network access manager will be used to make the request to the authentication server and the authenticated request to the web service.
See also
networkAccessManager()
QNetworkAccessManager
- PySide6.QtNetworkAuth.QAbstractOAuth.setReplyHandler(handler)¶
- Parameters
Sets the current reply handler to handler
.
Sets the current status to status
. This method is for use by classes based on QAbstractOAuth
.
See also
- PySide6.QtNetworkAuth.QAbstractOAuth.setToken(token)¶
- Parameters
token – str
This property holds This property holds the current authentication status..
- PySide6.QtNetworkAuth.QAbstractOAuth.token()¶
- Return type
str
- PySide6.QtNetworkAuth.QAbstractOAuth.tokenChanged(token)¶
- Parameters
token – str
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.