Reference¶
dapla_auth_client package¶
dapla_auth_client.auth module¶
- class AuthClient¶
Bases:
objectClient for retrieving authentication information.
- static fetch_email_from_credentials()¶
Retrieves an e-mail based on current Google Credentials. Potentially makes a Google API call.
- Return type:
str|None
- static fetch_google_credentials()¶
Fetches the Google credentials for the current user.
- Raises:
RuntimeError – If fails to fetch credentials.
- Return type:
Credentials- Returns:
The Google “Credentials” object.
- static fetch_google_token(request=None, scopes=None)¶
Fetches the Google token for the current user.
Scopes in the argument is ignored, but are kept for compatibility with the Credentials refresh handler method signature.
- Parameters:
request (
Request|None) – The GoogleAuthRequest object.scopes (
list[str] |None) – The scopes to request. This is ignored in this implementation.
- Raises:
RuntimeError – If the token exchange fails.
- Return type:
tuple[str,datetime]- Returns:
A tuple of (google-token, expiry).
- static fetch_google_token_from_oidc_exchange(request, scopes=None)¶
Fetches the Google token by exchanging an OIDC token.
- Parameters:
request (
Request) – The GoogleAuthRequest object.scopes (
list[str] |None) – The scopes to request. This is ignored in this implementation.
- Raises:
RuntimeError – If the request to the OIDC token exchange endpoint fails.
- Return type:
tuple[str,datetime]- Returns:
A tuple of (google-token, expiry).
- static fetch_personal_token(scopes=None, audiences=None)¶
If Dapla Region is Dapla Lab, retrieve the Keycloak token.
This method checks if the current Dapla Region is Dapla Lab and retrieves the Keycloak token for the current user. If the region is not Dapla Lab, it raises a RuntimeError.
- Parameters:
scopes (
list[str] |None) – Optional list of scopes to include in the token request (ex. current_group, all_groups). Defaults to current_group.audiences (
list[str] |None) – Optional list of audiences to include in the token exchange request.
- Raises:
RuntimeError – If the region is not DAPLA_LAB.
- Returns:
The Keycloak token for the current user.
- Return type:
str
- static get_current_dapla_metadata()¶
Read the DAPLA related environment variables and return them as a tuple.
- Return type:
tuple[DaplaEnvironment|None,DaplaService|None,DaplaRegion|None]
- static get_dapla_region()¶
Checks if the current Dapla Region is Dapla Lab.
- Return type:
DaplaRegion|None
- exception MissingConfigurationException(variable_name)¶
Bases:
ExceptionException raised when a required environment variable or configuration is missing.
- Parameters:
variable_name (str)
- Return type:
None