keycloak.openid_connection
Keycloak OpenID Connection Manager module.
The module contains mainly the implementation of KeycloakOpenIDConnection class. This is an extension of the ConnectionManager class, and handles the automatic refresh of openid tokens when required.
Classes
A class to help with OpenID connections which can auto refresh tokens. |
Module Contents
- class keycloak.openid_connection.KeycloakOpenIDConnection(server_url, grant_type=None, username=None, password=None, token=None, totp=None, realm_name='master', client_id='admin-cli', verify=True, client_secret_key=None, custom_headers=None, user_realm_name=None, timeout=60, cert=None, max_retries=1)[source]
Bases:
keycloak.connection.ConnectionManager
A class to help with OpenID connections which can auto refresh tokens.
- Parameters:
object (_type_) – _description_
- verify = True[source]
Return verify in use for request to the server.
- Returns:
Verify indicator
- Return type:
bool
- property client_secret_key[source]
Get client secret key.
- Returns:
Client secret key
- Return type:
str
- timeout = 60[source]
Return timeout in use for request to the server.
- Returns:
Timeout
- Return type:
int
- cert = None[source]
Return client certificates in use for request to the server.
- Returns:
Client certificate
- Return type:
Union[str,Tuple[str,str]]
- property expires_at[source]
Get token expiry time.
- Returns:
Datetime at which the current token will expire
- Return type:
datetime
- property keycloak_openid: keycloak.keycloak_openid.KeycloakOpenID[source]
Get the KeycloakOpenID object.
The KeycloakOpenID is used to refresh tokens
- Returns:
KeycloakOpenID
- Return type:
- refresh_token()[source]
Refresh the token.
- Raises:
KeycloakPostError – In case the refresh token request failed.
- raw_get(*args, **kwargs)[source]
Call connection.raw_get.
If auto_refresh is set for get and access_token is expired, it will refresh the token and try get once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response
- raw_post(*args, **kwargs)[source]
Call connection.raw_post.
If auto_refresh is set for post and access_token is expired, it will refresh the token and try post once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response
- raw_put(*args, **kwargs)[source]
Call connection.raw_put.
If auto_refresh is set for put and access_token is expired, it will refresh the token and try put once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response
- raw_delete(*args, **kwargs)[source]
Call connection.raw_delete.
If auto_refresh is set for delete and access_token is expired, it will refresh the token and try delete once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response
- async a_refresh_token()[source]
Refresh the token.
- Raises:
KeycloakPostError – In case the refresh token request failed.
- async a_raw_get(*args, **kwargs)[source]
Call connection.raw_get.
If auto_refresh is set for get and access_token is expired, it will refresh the token and try get once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response
- async a_raw_post(*args, **kwargs)[source]
Call connection.raw_post.
If auto_refresh is set for post and access_token is expired, it will refresh the token and try post once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response
- async a_raw_put(*args, **kwargs)[source]
Call connection.raw_put.
If auto_refresh is set for put and access_token is expired, it will refresh the token and try put once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response
- async a_raw_delete(*args, **kwargs)[source]
Call connection.raw_delete.
If auto_refresh is set for delete and access_token is expired, it will refresh the token and try delete once more.
- Parameters:
args (tuple) – Additional arguments
kwargs (dict) – Additional keyword arguments
- Returns:
Response
- Return type:
Response