OAuth Client
- class q2_sdk.models.oauth_client.OAuthToken(access_token, expires_in, refresh_token=None, token_type='Bearer')[source]
OAuthToken(access_token: str, expires_in: int, refresh_token: Optional[str] = None, token_type: str = ‘Bearer’)
-
access_token:
str
-
expires_in:
int
-
refresh_token:
Optional
[str
] = None
-
token_type:
str
= 'Bearer'
-
access_token:
- class q2_sdk.models.oauth_client.OAuthClient(cache)[source]
This class takes care of takes care of some of the grunt work of authenticating with OAuth, such as
Retrieving an access token
Refreshing an access token using a refresh token
Passing in an Authorization header
Caching the token until it exires
To use, create a child class that inherits from
OAuthClient
, define theget_token
and (optionally)refresh_token
functions, then pass an instance of your child class to a q2_requests function using theoauth_client
keyword argument.- property name: str
A unique string to be used for storing tokens in cache. By default, this will be the class name. If you plan to use this class to store tokens for multiple domains or endpoints, you should override this.
- property access_key: str
Key for storing OAuth access token in cache. You can override this for advanced use cases, but consider overriding
name
instead.
- property refresh_key: str
Key for storing OAuth refresh token in cache. You can override this for advanced use cases, but consider overriding
name
instead.
- property unauthorized_status_codes: list[int]
A list of HTTP status codes that indicate that the cached token is invalid. If a request returns one of these statuses, a new token will be aquired and the request will retry exactly once.
- async refresh_token(refresh_token)[source]
Define behavior for refreshing an access token from your IDP
- Return type: