Pyjo.GCP.Credentials.File - Credentials of a file¶
from Pyjo.GCP.Credentials.File import File
credentials = File(path='/etc/gcloud/key.json').credentials()
# Or import the module, as in Google Python Style Guide
import Pyjo.GCP.Config
import Pyjo.GCP.Credentials.File
config = Pyjo.GCP.Config.new()
# The file of gcloud auth application-default login, or None without it
provider = Pyjo.GCP.Credentials.File.new(path=config.adc_file(), optional=True, config=config)
provider.credentials_p().then(lambda credentials: print(credentials.project)).wait()
Pyjo.GCP.Credentials.File is the provider of the credentials of a
file of credentials of Google Cloud, as the one of
GOOGLE_APPLICATION_CREDENTIALS or of
gcloud auth application-default login, of the provider of its type:
authorized_user, ofPyjo.GCP.Credentials.AuthorizedUser,service_account, ofPyjo.GCP.Credentials.ServiceAccount, with the scopes of the provider,impersonated_service_account, ofPyjo.GCP.Credentials.Impersonated, with the scopes of the provider, and its source of the provider of the type ofsource_credentials, with the scope of IAM,external_account, ofPyjo.GCP.Credentials.IdentityPool, of a file, a URL or a certificate of X.509, ofPyjo.GCP.Credentials.Pluggable, of an executable, or ofPyjo.GCP.Credentials.AWS, of AWS, with the scopes of the provider,external_account_authorized_user, ofPyjo.GCP.Credentials.ExternalAccountAuthorizedUser.
The quota project of GOOGLE_CLOUD_QUOTA_PROJECT comes over the one of
the file, and the file of gcloud auth application-default login, which
has no project, has the one of the configuration of gcloud, core/project,
as google-auth has them.
See also¶
Pyjo.GCP.Credentials.Provider, Pyjo.GCP.Credentials.Chain,
Pyjo.GCP.Config, https://google.aip.dev/auth/4110.
Classes¶
- class Pyjo.GCP.Credentials.File.Pyjo_GCP_Credentials_File(*, path: str | None = None, optional: bool = False, config: Pyjo_GCP_Config | None = None, scopes: Sequence[str] | None = None, **kwargs: Any)[source]¶
Pyjo.GCP.Credentials.Fileinherits all attributes and methods fromPyjo.GCP.Credentials.Providerand implements the following new ones.- __init__(*, path: str | None = None, optional: bool = False, config: Pyjo_GCP_Config | None = None, scopes: Sequence[str] | None = None, **kwargs: Any) None[source]¶
provider = Pyjo.GCP.Credentials.File.new(path='/etc/gcloud/key.json') provider = Pyjo.GCP.Credentials.File.new(path=config.adc_file(), optional=True, config=config, scopes=['https://www.googleapis.com/auth/devstorage.read_only'])
Construct a new
Pyjo.GCP.Credentials.Fileobject, with the options ofPyjo.GCP.Credentials.Provider.
- config¶
config = provider.config
The configuration of the quota project and of gcloud, a new
Pyjo.GCP.Configobject by default.
- external_account_of(info: Mapping[str, Any], path: str = 'a file', *, scopes: Sequence[str] | None = None) Pyjo_GCP_Credentials_Provider[source]¶
provider = provider.external_account_of(info)
A new provider of the JSON object of a file of the type
external_account, of the kind of its source, asprovider_of(), or aPyjo.Exceptionof an invalid one.
- async fetch() Pyjo_GCP_Credentials | None[source]¶
credentials = await provider.fetch()
The credentials of the provider of the file, or
Nonewithoutpath, or without the file of anoptionalone.
- is_gcloud() bool[source]¶
boolean = provider.is_gcloud()
Whether
pathis the file ofgcloud auth application-default loginofconfig, also ofGOOGLE_APPLICATION_CREDENTIALS, as google-auth compares them.
- optional¶
boolean = provider.optional
Whether a file that does not exist has no credentials, as the one of
gcloud auth application-default login, rather than an error, as the one ofGOOGLE_APPLICATION_CREDENTIALS.
- path¶
path = provider.path
The path of the file, or
None, which has no credentials, as an emptyGOOGLE_APPLICATION_CREDENTIALS.
- provider_of(info: Mapping[str, Any], path: str = 'a file', *, scopes: Sequence[str] | None = None) Pyjo_GCP_Credentials_Provider[source]¶
source = provider.provider_of(info)
A new provider of the JSON object of a file of credentials, of its
type, with the user agent and the refresh of this one, and the scopes of the argument or ofscopes, or aPyjo.Exceptionof a type that is not supported.
- scopes¶
scopes = provider.scopes
The scopes of the token of the credentials that take scopes,
https://www.googleapis.com/auth/cloud-platformby default.