def test_from_filename(): info, signer = _service_account_info.from_filename( SERVICE_ACCOUNT_JSON_FILE) for key, value in six.iteritems(SERVICE_ACCOUNT_INFO): assert info[key] == value assert isinstance(signer, crypt.RSASigner) assert signer.key_id == SERVICE_ACCOUNT_INFO["private_key_id"]
def __init__(self, service_file=None, **kwargs): if service_file is not None: self._credential = from_filename(service_file) self._project_id = self._credential[0]['project_id'] self._token_uri = self._credential[0]['token_uri'] self._signer_email = self._credential[0]['client_email'] self._private_key = self._credential[0]['private_key'] self._signer = self._credential[1] self._scopes = _helpers.scopes_to_string(_SCOPES) self._token_expiration = _helpers.utcnow() super().__init__(service_file=service_file, **kwargs)
def from_service_account_file(cls, filename, **kwargs): """Creates a Credentials instance from a service account .json file in Google format. Args: filename (str): The path to the service account .json file. kwargs: Additional arguments to pass to the constructor. Returns: google.auth.jwt.Credentials: The constructed credentials. """ info, signer = _service_account_info.from_filename( filename, require=['client_email']) return cls._from_signer_and_info(signer, info, **kwargs)
def from_service_account_file(cls, filename, **kwargs): """Creates a credentials instance from a service account json file. Args: filename (str): The path to the service account json file. kwargs: Additional arguments to pass to the constructor. Returns: google.auth.service_account.IDTokenCredentials: The constructed credentials. """ info, signer = _service_account_info.from_filename( filename, require=["client_email", "token_uri"]) return cls._from_signer_and_info(signer, info, **kwargs)
def from_service_account_file(cls, filename, **kwargs): """Creates an OnDemandCredentials instance from a service account .json file in Google format. Args: filename (str): The path to the service account .json file. kwargs: Additional arguments to pass to the constructor. Returns: google.auth.jwt.OnDemandCredentials: The constructed credentials. """ info, signer = _service_account_info.from_filename( filename, require=['client_email']) return cls._from_signer_and_info(signer, info, **kwargs)