benchling_sdk.auth.client_credentials_oauth2 module¶
- class ClientCredentialsOAuth2¶
Bases:
benchling_api_client.v2.benchling_client.AuthorizationMethod
OAuth2 client credentials for authorization.
Use in combination with the Benchling() client constructor to be authorized with OAuth2 client_credentials grant type.
- __init__(client_id: str, client_secret: str, token_url: Optional[str] = None, httpx_client: Optional[httpx.Client] = None)¶
Initialize ClientCredentialsOAuth2.
- Parameters
client_id â Client id in client_credentials grant type
client_secret â Client secret in client_credentials grant type
token_url â A fully-qualified URL pointing at the access token request endpoint such as https://benchling.com/api/v2/token. Can be omitted to default to /api/v2/token appended to the server base URL.
httpx_client â An optional httpx Client which will be used to execute HTTP calls. The Client can be used to modify the behavior of the HTTP calls made to Benchling through means such as adding proxies and certificates or introducing retry logic for transport-level errors.
- class Token¶
Bases:
object
Represents an OAuth2 token response model.
- __init__(access_token: str, refresh_time: datetime)¶
Initialize Token.
- Parameters
access_token â The raw token value for authorizing with the API
refresh_time â Calculated value off of token time-to-live for when a new token should be generated.
- classmethod from_token_response(token_response)¶
Construct Token from deserializing token endpoint response.
Deserializes response from token endpoint and calculates expiry time with buffer for when token should be regenerated.
- Parameters
token_response â The response from an RFC6749 POST /token endpoint.