public abstract class ExternalAccountCredentials extends GoogleCredentials implements QuotaProjectIdProvider
Handles initializing external credentials, calls to STS, and service account impersonation.
| Modifier and Type | Class and Description |
|---|---|
static class |
ExternalAccountCredentials.Builder
Base builder for external account credentials.
|
OAuth2Credentials.CredentialsChangedListener| Modifier and Type | Field and Description |
|---|---|
protected ImpersonatedCredentials |
impersonatedCredentials |
protected HttpTransportFactory |
transportFactory |
| Modifier | Constructor and Description |
|---|---|
protected |
ExternalAccountCredentials(HttpTransportFactory transportFactory,
String audience,
String subjectTokenType,
String tokenUrl,
com.google.auth.oauth2.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.
|
protected |
ExternalAccountCredentials(HttpTransportFactory transportFactory,
String audience,
String subjectTokenType,
String tokenUrl,
com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource credentialSource,
String tokenInfoUrl,
String serviceAccountImpersonationUrl,
String quotaProjectId,
String clientId,
String clientSecret,
Collection<String> scopes,
com.google.auth.oauth2.EnvironmentProvider environmentProvider)
|
create, createDelegated, createScoped, createScoped, createScoped, createScopedRequired, getApplicationDefault, getApplicationDefault, newBuilder, toBuilderaddChangeListener, equals, getAccessToken, getAdditionalHeaders, getAuthenticationType, getFromServiceLoader, getRequestMetadataInternal, hashCode, hasRequestMetadata, hasRequestMetadataOnly, newInstance, refresh, refreshAccessToken, refreshIfExpired, removeChangeListener, toStringblockingGetToCallback, getRequestMetadataprotected transient HttpTransportFactory transportFactory
@Nullable protected final ImpersonatedCredentials impersonatedCredentials
protected ExternalAccountCredentials(HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource credentialSource, @Nullable String tokenInfoUrl, @Nullable String serviceAccountImpersonationUrl, @Nullable String quotaProjectId, @Nullable String clientId, @Nullable String clientSecret, @Nullable Collection<String> scopes)
transportFactory - HTTP transport factory, creates the transport used to get access tokensaudience - the STS audience which is usually the fully specified resource name of the
workload/workforce pool providersubjectTokenType - the STS subject token type based on the OAuth 2.0 token exchange spec.
Indicates the type of the security token in the credential filetokenUrl - the STS token exchange endpointtokenInfoUrl - the endpoint used to retrieve account related information. Required for
gCloud session account identification.credentialSource - the external credential sourceserviceAccountImpersonationUrl - the URL for the service account impersonation request.
This is only required for workload identity pools when APIs to be accessed have not
integrated with UberMint. If this is not available, the STS returned GCP access token is
directly used. May be null.quotaProjectId - the project used for quota and billing purposes. May be null.clientId - client ID of the service account from the console. May be null.clientSecret - client secret of the service account from the console. May be null.scopes - the scopes to request during the authorization grant. May be null.protected ExternalAccountCredentials(HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource credentialSource, @Nullable String tokenInfoUrl, @Nullable String serviceAccountImpersonationUrl, @Nullable String quotaProjectId, @Nullable String clientId, @Nullable String clientSecret, @Nullable Collection<String> scopes, @Nullable com.google.auth.oauth2.EnvironmentProvider environmentProvider)
environmentProvider - the environment provider. May be null. Defaults to SystemEnvironmentProvider.public void getRequestMetadata(URI uri, Executor executor, RequestMetadataCallback callback)
getRequestMetadata in class OAuth2Credentialspublic Map<String,List<String>> getRequestMetadata(URI uri) throws IOException
OAuth2CredentialsgetRequestMetadata in class OAuth2CredentialsIOExceptionpublic static ExternalAccountCredentials fromStream(InputStream credentialsStream) throws IOException
Returns IdentityPoolCredentials or AwsCredentials.
credentialsStream - the stream with the credential definitionIOException - if the credential cannot be created from the streampublic static ExternalAccountCredentials fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory) throws IOException
Returns a IdentityPoolCredentials or AwsCredentials.
credentialsStream - the stream with the credential definitiontransportFactory - the HTTP transport factory used to create the transport to get access
tokensIOException - if the credential cannot be created from the streamprotected AccessToken exchangeExternalCredentialForAccessToken(com.google.auth.oauth2.StsTokenExchangeRequest stsTokenExchangeRequest) throws IOException
stsTokenExchangeRequest - the STS token exchange requestOAuthException - if the call to STS failsIOExceptionpublic abstract String retrieveSubjectToken() throws IOException
Must be implemented by subclasses as the retrieval method is dependent on the credential source.
IOExceptionpublic String getAudience()
public String getSubjectTokenType()
public String getTokenUrl()
public String getTokenInfoUrl()
public com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource getCredentialSource()
@Nullable public String getQuotaProjectId()
getQuotaProjectId in interface QuotaProjectIdProvider@Nullable public Collection<String> getScopes()
Copyright © 2021 Google. All rights reserved.