QOAuth2AuthorizationCodeFlow — PyQt Documentation v6.9.0 (original) (raw)
PyQt6.QtNetworkAuth.QOAuth2AuthorizationCodeFlow
Inherits from QAbstractOAuth2.
Description¶
The QOAuth2AuthorizationCodeFlow class provides an implementation of the Authorization Code Grant flow.
This class implements the Authorization Code Grant flow, which is used both to obtain and to refresh access tokens. It is a redirection-based flow so the user will need access to a web browser.
As a redirection-based flow this class requires a proper reply handler to be set. See Qt OAuth2 Overview, QOAuthHttpServerReplyHandler, and QOAuthUriSchemeReplyHandler.
Enums¶
PkceMethod
List of available Proof Key for Code Exchange (PKCE) methods.
PKCE is a security measure to mitigate the risk of authorization code interception attacks. As such it is relevant for OAuth2 “Authorization Code” flow (grant) and in particular with native applications.
PKCE inserts additional parameters into authorization and access token requests. With the help of these parameters the authorization server is able to verify that an access token request originates from the same entity that issued the authorization request.
Member | Value | Description |
---|---|---|
None_ | 255 | PKCE is not used. |
Plain | 1 | The Plain PKCE method is used. Use this only if it is not possible to use S256. With Plain method the code challenge equals to the code verifier. |
S256 | 0 | The S256 PKCE method is used. This is the default and the recommended method for native applications. With the S256 method the code challenge is a base64url-encoded value of the SHA-256 of the code verifier. |
Methods¶
__init__(parent: QObject = None)
Constructs a QOAuth2AuthorizationCodeFlow object with parent object parent.
__init__(QNetworkAccessManager, parent: QObject = None)
Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager.
__init__(Optional[str], QNetworkAccessManager, parent: QObject = None)
Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager. The client identifier is set to clientIdentifier.
__init__(QUrl, QUrl, QNetworkAccessManager, parent: QObject = None)
Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager. The authenticate URL is set to authenticateUrl and the access token URL is set to accessTokenUrl.
__init__(Optional[str], QUrl, QUrl, QNetworkAccessManager, parent: QObject = None)
Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager. The client identifier is set to clientIdentifier the authenticate URL is set to authenticateUrl and the access token URL is set to accessTokenUrl.
accessTokenUrl() → QUrl
Returns the URL used to request the access token.
See also
buildAuthenticateUrl(parameters: dict[Optional[str], Sequence[Any]] = {}) → QUrl
Generates an authentication URL to be used in the Authorization Request using parameters.
grant()
TODO
pkceMethod() → PkceMethod
Returns the current PKCE method.
refreshAccessToken()
Call this function to refresh the token. Access tokens are not permanent. After a time specified along with the access token when it was obtained, the access token will become invalid.
If refreshing the token fails and an access token exists, the status is set to Granted, and to NotAuthenticated otherwise.
refreshTokensImplementation()
TODO
requestAccessToken(Optional[str])
Requests an access token from the received code. The code is received as a response when the user completes a successful authentication in the browser.
TODO
setAccessTokenUrl(QUrl)
Sets the URL used to request the access token to accessTokenUrl.
See also
setPkceMethod(PkceMethod, length: int = 43)
Sets the current PKCE method to method.
Optionally, the length parameter can be used to set the length of the code_verifier
. The value must be between 43 and 128 bytes. The ‘code verifier’ itself is random-generated by the library.
See also
Signals¶
accessTokenUrlChanged(QUrl)
TODO