PySide6.QtNetworkAuth.QAbstractOAuth¶
- class QAbstractOAuth¶
- The - QAbstractOAuthclass is the base of all implementations of OAuth authentication methods. More…- Inherited by: - QOAuth1,- QAbstractOAuth2,- QOAuth2AuthorizationCodeFlow- Synopsis¶- Properties¶- authorizationUrlᅟ- This property holds the URL used to request the Resource Owner Authorization as described in: The OAuth 1.0 Protocol: Resource Owner Authorization
- contentTypeᅟ- Content-Type to use when sending authorization parameters
- extraTokensᅟ- This property holds the extra tokens received from the server
- statusᅟ- This property holds the current authentication status
 - Methods¶
- def - callback()
- def - contentType()
- def - extraTokens()
- def - replyHandler()
- def - setContentType()
- def - setStatus()
- def - setToken()
- def - status()
- def - token()
 - Virtual methods¶- def - deleteResource()
- def - get()
- def - grant()
- def - head()
- def - post()
- def - prepareRequest()
- def - put()
 - Signals¶
- def - finished()
- def - granted()
- def - requestFailed()
- def - statusChanged()
- def - tokenChanged()
 - Static functions¶- 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¶- 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 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. 
 - class Stage¶
- Identifies an authentication stage. It’s passed to a - modifyParametersFunctionso 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. 
 - class 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, or its response was not successfully received (for example, due to a state mismatch). - 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. 
 - class 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. 
 - Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- 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 . - Access functions:
 - property clientIdentifierᅟ: str¶
 - Access functions:
 - property 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:
 - property extraTokensᅟ: Dictionary with keys of type .QString and values of type QVariant.¶
 - This property holds This property holds the extra tokens received from the server.. - Access functions:
 - property statusᅟ: QAbstractOAuth.Status¶
 - This property holds This property holds the current authentication status.. - Access functions:
- Signal - statusChanged()
 
 - property tokenᅟ: str¶
 - Access functions:
- Signal - tokenChanged()
 
 - Returns the authorization request URL. - See also - Getter of property - authorizationUrlᅟ.- Notification signal of property - authorizationUrlᅟ.- This signal is emitted when the - urlgenerated by- resourceOwnerAuthorization()is ready to be used in the web browser to allow the application to impersonate the user.- See also - 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 - clientIdentifier()¶
- Return type:
- str 
 
 - Returns the current client identifier used in the authentication process. - See also - Getter of property - clientIdentifierᅟ.- clientIdentifierChanged(clientIdentifier)¶
- Parameters:
- clientIdentifier – str 
 
 - Notification signal of property - clientIdentifierᅟ.- contentType()¶
- Return type:
 
 - Returns the current Content-Type used in authenticated calls. - See also - Getter of property - contentTypeᅟ.- contentTypeChanged(contentType)¶
- Parameters:
- contentType – - ContentType
 
 - Notification signal of property - contentTypeᅟ.- abstract deleteResource(url[, parameters=QVariantMap()])¶
- Parameters:
- url – - QUrl
- parameters – Dictionary with keys of type .QString and values of type QVariant. 
 
- Return type:
 
 - Sends an authenticated DELETE request and returns a new QNetworkReply. The - urland- parametersare used to create the request.- See also: Hypertext Transfer Protocol – HTTP/1.1: DELETE - extraTokens()¶
- Return type:
- Dictionary with keys of type .QString and values of type QVariant. 
 
 - Returns the extra tokens received from the server during authentication. - See also - Getter of property - extraTokensᅟ.- extraTokensChanged(tokens)¶
- Parameters:
- tokens – Dictionary with keys of type .QString and values of type QVariant. 
 
 - Notification signal of property - extraTokensᅟ.- finished(reply)¶
- Parameters:
- reply – - QNetworkReply
 
 - static generateRandomString(length)¶
- Parameters:
- length – int 
- Return type:
 
 - Generates a random string which could be used as state or nonce. The parameter - lengthdetermines the size of the generated string.- See also: The OAuth 1.0 Protocol: Nonce and Timestamp . - abstract get(url[, parameters=QVariantMap()])¶
- Parameters:
- url – - QUrl
- parameters – Dictionary with keys of type .QString and values of type QVariant. 
 
- Return type:
 
 - Sends an authenticated GET request and returns a new QNetworkReply. The - urland- parametersare used to create the request.- See also: Hypertext Transfer Protocol – HTTP/1.1: GET - abstract 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.- granted()¶
 - This signal is emitted when the authorization flow finishes successfully. - abstract head(url[, parameters=QVariantMap()])¶
- Parameters:
- url – - QUrl
- parameters – Dictionary with keys of type .QString and values of type QVariant. 
 
- Return type:
 
 - Sends an authenticated HEAD request and returns a new QNetworkReply. The - urland- parametersare used to create the request.- See also: Hypertext Transfer Protocol – HTTP/1.1: HEAD - 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. - abstract post(url[, parameters=QVariantMap()])¶
- Parameters:
- url – - QUrl
- parameters – Dictionary with keys of type .QString and values of type QVariant. 
 
- Return type:
 
 - Sends an authenticated POST request and returns a new QNetworkReply. The - urland- parametersare used to create the request.- See also: Hypertext Transfer Protocol – HTTP/1.1: POST - abstract prepareRequest(request, verb[, body=QByteArray()])¶
- Parameters:
- request – - QNetworkRequest
- verb – - QByteArray
- body – - QByteArray
 
 
 - Authorizes the given - requestby adding a header and- bodyto it required for authenticated requests.- The - verbmust be a valid HTTP verb and the same as the one that will be used to send the- request.- abstract put(url[, parameters=QVariantMap()])¶
- Parameters:
- url – - QUrl
- parameters – Dictionary with keys of type .QString and values of type QVariant. 
 
- Return type:
 
 - Sends an authenticated PUT request and returns a new QNetworkReply. The - urland- parametersare used to create the request.- See also: Hypertext Transfer Protocol – HTTP/1.1: PUT - replyDataReceived(data)¶
- Parameters:
- data – - QByteArray
 
 - replyHandler()¶
- Return type:
 
 - Returns the reply handler currently in use. - This signal is emitted to indicate that a request to a server has failed. The - errorsupplied indicates how the request failed.- See also - resourceOwnerAuthorization(url, parameters)¶
- Parameters:
- url – - QUrl
- parameters – .QMultiMapQString,QVariant 
 
 
 - Builds the resource owner authorization URL to be used in the web browser: - urlis 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 - Sets the authorization request URL to - url. This address will be used to allow the user to grant the application the ability to make authenticated calls on behalf of the user.- See also - Setter of property - authorizationUrlᅟ.- setClientIdentifier(clientIdentifier)¶
- Parameters:
- clientIdentifier – str 
 
 - Sets the current client identifier to - clientIdentifier.- See also - Setter of property - clientIdentifierᅟ.- setContentType(contentType)¶
- Parameters:
- contentType – - ContentType
 
 - Sets the current Content-Type to - contentType.- See also - Setter of property - contentTypeᅟ.- setModifyParametersFunction(modifyParametersFunction)¶
- Parameters:
- modifyParametersFunction – object 
 
 - setNetworkAccessManager(networkAccessManager)¶
- Parameters:
- networkAccessManager – - QNetworkAccessManager
 
 - Sets the network manager to - networkAccessManager.- QAbstractOAuthdoes 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.- setReplyHandler(handler)¶
- Parameters:
- handler – - QAbstractOAuthReplyHandler
 
 - 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 - setToken(token)¶
- Parameters:
- token – str 
 
 - Sets the token used to sign authenticated requests to - token.- See also - Setter of property - tokenᅟ.- Returns the current authentication status. - See also - Getter of property - statusᅟ.- Notification signal of property - statusᅟ.- token()¶
- Return type:
- str 
 
 - Returns the token used to sign the authenticated requests. - See also - Getter of property - tokenᅟ.- tokenChanged(token)¶
- Parameters:
- token – str 
 
 - Notification signal of property - tokenᅟ.