Copied!

ExecutableSource enables the exchange of workload identity pool external credentials for Google access tokens by retrieving 3rd party tokens through a user supplied executable. These scripts/executables are completely independent of the Google Cloud Auth libraries. These credentials plug into ADC and will call the specified executable to retrieve the 3rd party token to be exchanged for a Google access token.

To use these credentials, the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment variable must be set to '1'. This is for security reasons.

Both OIDC and SAML are supported. The executable must adhere to a specific response format defined below.

The executable must print out the 3rd party token to STDOUT in JSON format. When an output_file is specified in the credential configuration, the executable must also handle writing the JSON response to this file.

The "expiration_time" field in the JSON response is only required for successful responses when an output file was specified in the credential configuration

The auth libraries will populate certain environment variables that will be accessible by the executable, such as: GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE, GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE, GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE, GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL, and GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE.

CloneableInstantiable
Methods
public __construct(string $command, ?string $outputFile, ?Google\Auth\ExecutableHandler\ExecutableHandler $executableHandler = NULL)
 
  • param string $command The string command to run to get the subject token.
  • param string|null $outputFile
public fetchSubjectToken(?callable $httpHandler = NULL) : string
 
  • param callable|null $httpHandler unused.
  • return string
  • throws \RuntimeException if the executable is not allowed to run.
  • throws \ExecutableResponseError if the executable response is invalid.
public getCacheKey() : ?string
 

Gets the unique key for caching The format for the cache key is: Command.OutputFile

  • return ?string
Constants
private Google\Auth\CredentialSource\ExecutableSource::GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES = 'GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES'
private Google\Auth\CredentialSource\ExecutableSource::OIDC_SUBJECT_TOKEN_TYPE1 = 'urn:ietf:params:oauth:token-type:id_token'
private Google\Auth\CredentialSource\ExecutableSource::OIDC_SUBJECT_TOKEN_TYPE2 = 'urn:ietf:params:oauth:token-type:jwt'
private Google\Auth\CredentialSource\ExecutableSource::SAML_SUBJECT_TOKEN_TYPE = 'urn:ietf:params:oauth:token-type:saml2'
Properties
private string $command
private Google\Auth\ExecutableHandler\ExecutableHandler $executableHandler
private ?string $outputFile
Methods
private getCachedExecutableResponse() : ?array
 
  • return array<string,mixed>|null
private parseExecutableResponse(string $response) : array
 
  • return array<string,mixed>
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration