CredentialsLoader contains the behaviour used to locate and find default
credentials files on the file system.

Abstract
ImplementsGoogle\Auth\FetchAuthTokenInterface
Constants
public Google\Auth\CredentialsLoader::AUTH_METADATA_KEY = 'authorization'
public Google\Auth\CredentialsLoader::ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS'
public Google\Auth\CredentialsLoader::NON_WINDOWS_WELL_KNOWN_PATH_BASE = '.config'
public Google\Auth\CredentialsLoader::TOKEN_CREDENTIAL_URI = 'https://oauth2.googleapis.com/token'
public Google\Auth\CredentialsLoader::WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json'
Methods
public abstract Google\Auth\FetchAuthTokenInterface::fetchAuthToken(?callable $httpHandler = NULL)
 

Fetches the auth tokens based on the current state.

  • return array a hash of auth tokens
public static fromEnv()
 

Load a JSON key from the path specified in the environment.

Load a JSON key from the path specified in the environment
variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
GOOGLE_APPLICATION_CREDENTIALS is not specified.

  • return array|null JSON key | null
public static fromWellKnownFile()
 

Load a JSON key from a well known path.

The well known path is OS dependent:

  • windows: %APPDATA%/gcloud/application_default_credentials.json
  • others: $HOME/.config/gcloud/application_default_credentials.json

If the file does not exist, this returns null.

  • return array|null JSON key | null
public abstract Google\Auth\FetchAuthTokenInterface::getCacheKey()
 

Obtains a key that can used to cache the results of #fetchAuthToken.

If the value is empty, the auth token is not cached.

  • return string a key that may be used to cache the auth token.
public abstract Google\Auth\FetchAuthTokenInterface::getLastReceivedToken()
 

Returns an associative array with the token and
expiration time.

  • return null|array { The last received access token.
  • var string $access_token The access token string.
  • var int $expires_at The time the token expires as a UNIX timestamp. }
public getUpdateMetadataFunc()
 

export a callback function which updates runtime metadata.

  • return array updateMetadata function
public static makeCredentials( $scope, array $jsonKey)
 

Create a new Credentials instance.

  • return ServiceAccountCredentials|\UserRefreshCredentials
public static makeHttpClient(Google\Auth\FetchAuthTokenInterface $fetcher, array $httpClientOptions = [], ?callable $httpHandler = NULL, ?callable $tokenCallback = NULL)
 

Create an authorized HTTP Client from an instance of FetchAuthTokenInterface.

public static makeInsecureCredentials()
 

Create a new instance of InsecureCredentials.

  • return InsecureCredentials
public updateMetadata( $metadata, $authUri = NULL, ?callable $httpHandler = NULL)
 

Updates metadata with the authorization token.

  • return array updated metadata hashmap
Methods
private static isOnWindows()
 
  • return bool
private static unableToReadEnv( $cause)
 
  • return string
Methods
public static fromEnv()
 

Load a JSON key from the path specified in the environment.

Load a JSON key from the path specified in the environment
variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
GOOGLE_APPLICATION_CREDENTIALS is not specified.

  • return array|null JSON key | null
public static fromWellKnownFile()
 

Load a JSON key from a well known path.

The well known path is OS dependent:

  • windows: %APPDATA%/gcloud/application_default_credentials.json
  • others: $HOME/.config/gcloud/application_default_credentials.json

If the file does not exist, this returns null.

  • return array|null JSON key | null
private static isOnWindows()
 
  • return bool
public static makeCredentials( $scope, array $jsonKey)
 

Create a new Credentials instance.

  • return ServiceAccountCredentials|\UserRefreshCredentials
public static makeHttpClient(Google\Auth\FetchAuthTokenInterface $fetcher, array $httpClientOptions = [], ?callable $httpHandler = NULL, ?callable $tokenCallback = NULL)
 

Create an authorized HTTP Client from an instance of FetchAuthTokenInterface.

public static makeInsecureCredentials()
 

Create a new instance of InsecureCredentials.

  • return InsecureCredentials
private static unableToReadEnv( $cause)
 
  • return string
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only