External Account Credentials.
This module provides credentials that exchange workload identity pool external credentials for Google access tokens. This facilitates accessing Google Cloud Platform resources from on-prem and non-Google Cloud platforms (e.g. AWS, Microsoft Azure, OIDC identity providers), using native credentials retrieved from the current environment without the need to copy, save and manage long-lived service account credentials.
Specifically, this is intended to use access tokens acquired using the GCP STS token exchange endpoint following the OAuth 2.0 Token Exchange spec.
Bases: object
A context class that contains information about the requested third party credential that is passed to AWS security credential and subject token suppliers.
The requested subject token type based on the Oauth2.0 token exchange spec. Expected values include:
“urn:ietf:params:oauth:token-type:jwt” “urn:ietf:params:oauth:token-type:id-token” “urn:ietf:params:oauth:token-type:saml2” “urn:ietf:params:aws:token-type:aws4_request”
The requested audience for the subject token.
Bases: Scoped
, CredentialsWithQuotaProject
, CredentialsWithTokenUri
Base class for all external account credentials.
This is used to instantiate Credentials for exchanging external account credentials for Google access token and authorizing requests to Google APIs. The base class implements the common logic for exchanging external account credentials for Google access tokens.
Instantiates an external account credentials object.
audience (str) – The STS audience field.
subject_token_type (str) –
The subject token type based on the Oauth2.0 token exchange spec. Expected values include:
“urn:ietf:params:oauth:token-type:jwt” “urn:ietf:params:oauth:token-type:id-token” “urn:ietf:params:oauth:token-type:saml2” “urn:ietf:params:aws:token-type:aws4_request”
token_url (str) – The STS endpoint URL.
credential_source (Mapping) – The credential source dictionary.
service_account_impersonation_url (Optional
str
) – The optional service account impersonation generateAccessToken URL.
token_info_url (str) – The optional STS endpoint URL for token introspection.
quota_project_id (Optional
str
) – The optional quota project ID.
scopes (Optional
Sequence
str
) – Optional scopes to request during the authorization grant.
default_scopes (Optional
Sequence
str
) – Default scopes passed by a Google client library. Use ‘scopes’ for user-defined scopes.
workforce_pool_user_project (Optona[str]) – The optional workforce pool user project number when the credential corresponds to a workforce pool and not a workload identity pool. The underlying principal must still have serviceusage.services.use IAM permission to use the project for billing/quota.
universe_domain (str) – The universe domain. The default universe domain is googleapis.com.
trust_boundary (str) – String representation of trust boundary meta.
google.auth.exceptions.RefreshError – If the generateAccessToken endpoint returned an error.
Generates the dictionary representation of the current credentials.
reverse of “from_info” defined on the subclasses of this class. It is useful for serializing the current credentials so it can deserialized later.
Mapping
Returns the service account email if service account impersonation is used.
Returns whether the credentials represent a user (True) or workload (False). Workloads behave similarly to service accounts. Currently workloads will use service account impersonation but will eventually not require impersonation. As a result, this property is more reliable than the service account email property in determining if the credentials represent a user or workload.
workload.
Returns whether the credentials represent a workforce pool (True) or workload (False) based on the credentials’ audience.
This will also return True for impersonated workforce pool credentials.
represent a workload.
Checks if the credentials requires scopes.
True if there are no scopes set otherwise False.
The project number corresponding to the workload identity pool.
The credential information JSON.
The credential information will be added to auth related error messages by client library.
Create a copy of these credentials with the specified scopes.
scopes (Sequence
str
) – The list of scopes to attach to the current credentials.
NotImplementedError – If the credentials’ scopes can not be changed. This can be avoided by checking requires_scopes
before calling this method.
Retrieves the subject token using the credential_source object.
request (google.auth.transport.Request) – A callable used to make HTTP requests.
The retrieved subject token.
Retrieves the project ID corresponding to the workload identity or workforce pool. For workforce pool credentials, it returns the project ID corresponding to the workforce_pool_user_project.
When not determinable, None is returned.
This is introduced to support the current pattern of using the Auth library:
credentials, project_id = google.auth.default()
The resource may not have permission (resourcemanager.projects.get) to call this API or the required scopes may not be selected: https://cloud.google.com/resource-manager/reference/rest/v1/projects/get#authorization-scopes
request (google.auth.transport.Request) – A callable used to make HTTP requests.
or workforce pool if determinable.
Refreshes the access token.
request (google.auth.transport.Request) – The object used to make HTTP requests.
google.auth.exceptions.RefreshError – If the credentials could not be refreshed.
Returns a copy of these credentials with a modified quota project.
quota_project_id (str) – The project to use for quota and billing purposes
A new credentials instance.
Returns a copy of these credentials with a modified token uri.
token_uri (str) – The uri to use for fetching/exchanging tokens
A new credentials instance.
Returns a copy of these credentials with a modified universe domain.
universe_domain (str) – The universe domain to use
A new credentials instance.
Apply the token to the authentication header.
Performs credential-specific before request logic.
Refreshes the credentials if necessary, then calls apply()
to apply the token to the authentication header.
request (google.auth.transport.Request) – The object used to make HTTP requests.
method (str) – The request’s HTTP method or the RPC method being invoked.
url (str) – The request’s URI or the RPC service’s URI.
headers (Mapping) – The request’s headers.
Checks if the credentials are expired.
Note that credentials can be invalid but not expired because Credentials with expiry
set to None is considered to never expire.
Deprecated since version v2.24.0: Prefer checking token_state
instead.
Creates a Credentials instance from parsed external account info.
credentials.
InvalidValue – For invalid parameters.
Checks if the credentials have the given scopes.
Project to use for quota and billing purposes.
See :obj:`TokenState
The universe domain value.
Checks the validity of the credentials.
This is True if the credentials have a token
and the token is not expired
.
Deprecated since version v2.24.0: Prefer checking token_state
instead.
When the token expires and is no longer valid. If this is None, the token is assumed to never expire.
Creates a Credentials instance from an external account json file.
filename (str) – The path to the external account json file.
kwargs – Additional arguments to pass to the constructor.
credentials.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4