# Class ExternalAccountCredentials (1.46.0)

1.46.0 (latest) 1.43.0 1.42.1 1.41.0 1.40.0 1.39.1 1.38.0 1.37.1 1.36.0 1.35.0 1.34.0 1.33.1 1.32.1 1.31.0 1.30.1 1.29.1-SNAPSHOT 1.28.0 1.27.0 1.26.0 1.25.0 1.24.1 1.20.0 1.19.0 1.18.0 1.7.0 1.6.1 1.4.0 1.3.0

    public abstract class ExternalAccountCredentials extends GoogleCredentials

Base external account credentials class.

Handles initializing external credentials, calls to the Security Token Service, and service
account impersonation.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> [Credentials](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.Credentials) \> [OAuth2Credentials](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials) \> [GoogleCredentials](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials) \> ExternalAccountCredentials

## Inherited Members

[Credentials.blockingGetToCallback(URI,RequestMetadataCallback)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.Credentials#com_google_auth_Credentials_blockingGetToCallback_java_net_URI_com_google_auth_RequestMetadataCallback_) [Credentials.getMetricsCredentialType()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.Credentials#com_google_auth_Credentials_getMetricsCredentialType__) [Credentials.getRequestMetadata()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.Credentials#com_google_auth_Credentials_getRequestMetadata__) [GoogleCredentials.create(AccessToken)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_create_com_google_auth_oauth2_AccessToken_) [GoogleCredentials.create(String,AccessToken)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_create_java_lang_String_com_google_auth_oauth2_AccessToken_) [GoogleCredentials.createDelegated(String)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_createDelegated_java_lang_String_) [GoogleCredentials.createScoped(String)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_createScoped_java_lang_String____) [GoogleCredentials.createScoped(Collection\<String\>)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_createScoped_java_util_Collection_java_lang_String__) [GoogleCredentials.createScoped(Collection\<String\>,Collection\<String\>)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_createScoped_java_util_Collection_java_lang_String__java_util_Collection_java_lang_String__) [GoogleCredentials.createScopedRequired()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_createScopedRequired__) [GoogleCredentials.createWithCustomRetryStrategy(boolean)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_createWithCustomRetryStrategy_boolean_) [GoogleCredentials.createWithQuotaProject(String)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_createWithQuotaProject_java_lang_String_) [GoogleCredentials.equals(Object)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_equals_java_lang_Object_) [GoogleCredentials.fromStream(InputStream)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_fromStream_java_io_InputStream_) [GoogleCredentials.fromStream(InputStream,HttpTransportFactory)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_fromStream_java_io_InputStream_com_google_auth_http_HttpTransportFactory_) [GoogleCredentials.getAdditionalHeaders()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getAdditionalHeaders__) [GoogleCredentials.getApplicationDefault()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getApplicationDefault__) [GoogleCredentials.getApplicationDefault(HttpTransportFactory)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getApplicationDefault_com_google_auth_http_HttpTransportFactory_) [GoogleCredentials.getCredentialInfo()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getCredentialInfo__) [GoogleCredentials.getProjectId()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getProjectId__) [GoogleCredentials.getQuotaProjectId()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getQuotaProjectId__) [GoogleCredentials.getUniverseDomain()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getUniverseDomain__) [GoogleCredentials.hashCode()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_hashCode__) [GoogleCredentials.isExplicitUniverseDomain()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_isExplicitUniverseDomain__) [GoogleCredentials.newBuilder()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_newBuilder__) [GoogleCredentials.toBuilder()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_toBuilder__) [GoogleCredentials.toString()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_toString__) [GoogleCredentials.toStringHelper()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_toStringHelper__) [OAuth2Credentials.\<T\>getFromServiceLoader(Class\<? extends T\>,T)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials__T_getFromServiceLoader_java_lang_Class___extends_T__T_) [OAuth2Credentials.addChangeListener(OAuth2Credentials.CredentialsChangedListener)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_addChangeListener_com_google_auth_oauth2_OAuth2Credentials_CredentialsChangedListener_) [OAuth2Credentials.getAccessToken()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getAccessToken__) [OAuth2Credentials.getAuthenticationType()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getAuthenticationType__) [OAuth2Credentials.getRequestMetadata(URI)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getRequestMetadata_java_net_URI_) [OAuth2Credentials.getRequestMetadata(URI,Executor,RequestMetadataCallback)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getRequestMetadata_java_net_URI_java_util_concurrent_Executor_com_google_auth_RequestMetadataCallback_) [OAuth2Credentials.getRequestMetadataInternal()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getRequestMetadataInternal__) [OAuth2Credentials.hasRequestMetadata()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_hasRequestMetadata__) [OAuth2Credentials.hasRequestMetadataOnly()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_hasRequestMetadataOnly__) [OAuth2Credentials.newInstance(String)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_newInstance_java_lang_String_) [OAuth2Credentials.refresh()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_refresh__) [OAuth2Credentials.refreshAccessToken()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_refreshAccessToken__) [OAuth2Credentials.refreshIfExpired()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_refreshIfExpired__) [OAuth2Credentials.removeChangeListener(OAuth2Credentials.CredentialsChangedListener)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_removeChangeListener_com_google_auth_oauth2_OAuth2Credentials_CredentialsChangedListener_) [Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### fromStream(InputStream credentialsStream)

    public static ExternalAccountCredentials fromStream(InputStream credentialsStream)

Returns credentials defined by a JSON file stream.

Returns [IdentityPoolCredentials](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.IdentityPoolCredentials) or [AwsCredentials](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.AwsCredentials).

Important: If you accept a credential configuration (credential JSON/File/Stream) from an
external source for authentication to Google Cloud Platform, you must validate it before
providing it to any Google API or library. Providing an unvalidated credential configuration to
Google APIs can compromise the security of your systems and data. For more information, refer
to {@see [documentation](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials)}.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `credentialsStream` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` the stream with the credential definition |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.ExternalAccountCredentials` | the credential defined by the credentialsStream |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | if the credential cannot be created from the stream |

### fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory)

    public static ExternalAccountCredentials fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory)

Returns credentials defined by a JSON file stream.

Returns a [IdentityPoolCredentials](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.IdentityPoolCredentials) or [AwsCredentials](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.AwsCredentials).

Important: If you accept a credential configuration (credential JSON/File/Stream) from an
external source for authentication to Google Cloud Platform, you must validate it before
providing it to any Google API or library. Providing an unvalidated credential configuration to
Google APIs can compromise the security of your systems and data. For more information, refer
to {@see [documentation](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials)}.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `credentialsStream` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` the stream with the credential definition |
| `transportFactory` | `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.http.HttpTransportFactory` the HTTP transport factory used to create the transport to get access tokens |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.ExternalAccountCredentials` | the credential defined by the credentialsStream |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | if the credential cannot be created from the stream |

## Constructors

### ExternalAccountCredentials(HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, ExternalAccountCredentials.CredentialSource credentialSource, String tokenInfoUrl, String serviceAccountImpersonationUrl, String quotaProjectId, String clientId, String clientSecret, Collection\<String\> scopes)

    protected ExternalAccountCredentials(HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, ExternalAccountCredentials.CredentialSource credentialSource, String tokenInfoUrl, String serviceAccountImpersonationUrl, String quotaProjectId, String clientId, String clientSecret, Collection<String> scopes)

Constructor with minimum identifying information and custom HTTP transport. Does not support
workforce credentials.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `transportFactory` | `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.http.HttpTransportFactory` HTTP transport factory, creates the transport used to get access tokens |
| `audience` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the Security Token Service audience, which is usually the fully specified resource name of the workload/workforce pool provider |
| `subjectTokenType` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the Security Token Service subject token type based on the OAuth 2.0 token exchange spec. Indicates the type of the security token in the credential file |
| `tokenUrl` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the Security Token Service token exchange endpoint |
| `credentialSource` | `com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource` the external credential source |
| `tokenInfoUrl` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the endpoint used to retrieve account related information. Required for gCloud session account identification. |
| `serviceAccountImpersonationUrl` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the URL for the service account impersonation request. This URL is required for some APIs. If this URL is not available, the access token from the Security Token Service is used directly. May be null. |
| `quotaProjectId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the project used for quota and billing purposes. May be null. |
| `clientId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client ID of the service account from the console. May be null. |
| `clientSecret` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client secret of the service account from the console. May be null. |
| `scopes` | `https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` the scopes to request during the authorization grant. May be null. |

### ExternalAccountCredentials(HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, ExternalAccountCredentials.CredentialSource credentialSource, String tokenInfoUrl, String serviceAccountImpersonationUrl, String quotaProjectId, String clientId, String clientSecret, Collection\<String\> scopes, EnvironmentProvider environmentProvider)

    protected ExternalAccountCredentials(HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, ExternalAccountCredentials.CredentialSource credentialSource, String tokenInfoUrl, String serviceAccountImpersonationUrl, String quotaProjectId, String clientId, String clientSecret, Collection<String> scopes, EnvironmentProvider environmentProvider)

Constructor with minimum identifying information and custom HTTP transport. Does not support
workforce credentials.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `transportFactory` | `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.http.HttpTransportFactory` HTTP transport factory, creates the transport used to get access tokens |
| `audience` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the Security Token Service audience, which is usually the fully specified resource name of the workload/workforce pool provider |
| `subjectTokenType` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the Security Token Service subject token type based on the OAuth 2.0 token exchange spec. Indicates the type of the security token in the credential file |
| `tokenUrl` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the Security Token Service token exchange endpoint |
| `credentialSource` | `com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource` the external credential source |
| `tokenInfoUrl` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the endpoint used to retrieve account related information. Required for gCloud session account identification. |
| `serviceAccountImpersonationUrl` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the URL for the service account impersonation request. This URL is required for some APIs. If this URL is not available, the access token from the Security Token Service is used directly. May be null. |
| `quotaProjectId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the project used for quota and billing purposes. May be null. |
| `clientId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client ID of the service account from the console. May be null. |
| `clientSecret` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client secret of the service account from the console. May be null. |
| `scopes` | `https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` the scopes to request during the authorization grant. May be null. |
| `environmentProvider` | `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.EnvironmentProvider` the environment provider. May be null. Defaults to [SystemEnvironmentProvider](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.SystemEnvironmentProvider). |

### ExternalAccountCredentials(ExternalAccountCredentials.Builder builder)

    protected ExternalAccountCredentials(ExternalAccountCredentials.Builder builder)

Internal constructor with minimum identifying information and custom HTTP transport. See [ExternalAccountCredentials.Builder](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.ExternalAccountCredentials.Builder).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `builder` | `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.ExternalAccountCredentials.Builder` the `Builder` object used to construct the credentials. |

## Fields

### impersonatedCredentials

    protected ImpersonatedCredentials impersonatedCredentials

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.ImpersonatedCredentials` |   |

### transportFactory

    protected transient HttpTransportFactory transportFactory

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.http.HttpTransportFactory` |   |

## Methods

### exchangeExternalCredentialForAccessToken(StsTokenExchangeRequest stsTokenExchangeRequest)

    protected AccessToken exchangeExternalCredentialForAccessToken(StsTokenExchangeRequest stsTokenExchangeRequest)

Exchanges the external credential for a Google Cloud access token.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stsTokenExchangeRequest` | `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.StsTokenExchangeRequest` the Security Token Service token exchange request |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.AccessToken` | the access token returned by the Security Token Service |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | if the call to the Security Token Service fails |

### getAudience()

    public String getAudience()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getClientId()

    public String getClientId()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getClientSecret()

    public String getClientSecret()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getCredentialSource()

    public ExternalAccountCredentials.CredentialSource getCredentialSource()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource` |   |

### getRequestMetadata(URI uri)

    public Map<String,List<String>> getRequestMetadata(URI uri)

Provide the request metadata by ensuring there is a current access token and providing it as an
authorization bearer token.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `uri` | `https://docs.oracle.com/javase/8/docs/api/java/net/URI.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>>` |   |

**Overrides** [OAuth2Credentials.getRequestMetadata(URI uri)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getRequestMetadata_java_net_URI_)

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### getRequestMetadata(URI uri, Executor executor, RequestMetadataCallback callback)

    public void getRequestMetadata(URI uri, Executor executor, RequestMetadataCallback callback)

Get the current request metadata without blocking.

This should be called by the transport layer on each request, and the data should be
populated in headers or other context. The implementation can either call the callback inline
or asynchronously. Either way it should **never block** in this method. The
executor is provided for tasks that may block.

The default implementation will just call [#getRequestMetadata(URI)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.ExternalAccountCredentials#com_google_auth_oauth2_ExternalAccountCredentials_getRequestMetadata_java_net_URI_) then the callback
from the given executor.

The convention for handling binary data is for the key in the returned map to end with
`"-bin"` and for the corresponding values to be base64 encoded.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `uri` | `https://docs.oracle.com/javase/8/docs/api/java/net/URI.html` |
| `executor` | `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executor.html` |
| `callback` | `https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.RequestMetadataCallback` |

**Overrides** [OAuth2Credentials.getRequestMetadata(URI uri, Executor executor, RequestMetadataCallback callback)](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getRequestMetadata_java_net_URI_java_util_concurrent_Executor_com_google_auth_RequestMetadataCallback_)

### getScopes()

    public Collection<String> getScopes()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### getServiceAccountEmail()

    public String getServiceAccountEmail()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The service account email to be impersonated, if available |

### getServiceAccountImpersonationOptions()

    public ExternalAccountCredentials.ServiceAccountImpersonationOptions getServiceAccountImpersonationOptions()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.auth.oauth2.ExternalAccountCredentials.ServiceAccountImpersonationOptions` |   |

### getServiceAccountImpersonationUrl()

    public String getServiceAccountImpersonationUrl()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getSubjectTokenType()

    public String getSubjectTokenType()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getTokenInfoUrl()

    public String getTokenInfoUrl()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getTokenUrl()

    public String getTokenUrl()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getUniverseDomain()

    public String getUniverseDomain()

Gets the universe domain for the credential.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [GoogleCredentials.getUniverseDomain()](https://docs.cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials#com_google_auth_oauth2_GoogleCredentials_getUniverseDomain__)

### getWorkforcePoolUserProject()

    public String getWorkforcePoolUserProject()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### isWorkforcePoolConfiguration()

    public boolean isWorkforcePoolConfiguration()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | whether the current configuration is for Workforce Pools (which enable 3p user identities, rather than workloads) |

### retrieveSubjectToken()

    public abstract String retrieveSubjectToken()

Retrieves the external subject token to be exchanged for a Google Cloud access token.

Must be implemented by subclasses as the retrieval method is dependent on the credential
source.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | the external subject token |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | if the subject token cannot be retrieved |