Class GoogleCredentials (1.6.1)
Stay organized with collections
Save and categorize content based on your preferences.
publicclass GoogleCredentialsextendsOAuth2CredentialsBase type for credentials for authorizing calls to Google APIs using OAuth2.
Inherited Members
Static Methods
create(AccessToken accessToken)
publicstaticGoogleCredentialscreate(AccessTokenaccessToken)Returns the credentials instance from the given access token.
GoogleCredentials
the credentials instance
fromStream(InputStream credentialsStream)
publicstaticGoogleCredentialsfromStream(InputStreamcredentialsStream)Returns credentials defined by a JSON file stream.
The stream can contain a Service Account key file in JSON format from the Google Developers Console or a stored user credential using the format supported by the Cloud SDK.
GoogleCredentials
the credential defined by the credentialsStream.
IOException
if the credential cannot be created from the stream.
fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory)
publicstaticGoogleCredentialsfromStream(InputStreamcredentialsStream,HttpTransportFactorytransportFactory)Returns credentials defined by a JSON file stream.
The stream can contain a Service Account key file in JSON format from the Google Developers Console or a stored user credential using the format supported by the Cloud SDK.
transportFactory
HttpTransportFactory HTTP transport factory, creates the transport used to get access tokens.
GoogleCredentials
the credential defined by the credentialsStream.
IOException
if the credential cannot be created from the stream.
getApplicationDefault()
publicstaticGoogleCredentialsgetApplicationDefault()Returns the Application Default Credentials.
Returns the Application Default Credentials which are used to identify and authorize the whole application. The following are searched (in order) to find the Application Default Credentials:
- Credentials file pointed to by the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable - Credentials provided by the Google Cloud SDK.
gcloud auth application-default loginfor user account credentials.gcloud auth application-default login --impersonate-service-accountfor impersonated service account credentials.
- Google App Engine built-in credentials
- Google Cloud Shell built-in credentials
- Google Compute Engine built-in credentials
GoogleCredentials
the credentials instance.
IOException
if the credentials cannot be created in the current environment.
getApplicationDefault(HttpTransportFactory transportFactory)
publicstaticGoogleCredentialsgetApplicationDefault(HttpTransportFactorytransportFactory)Returns the Application Default Credentials.
Returns the Application Default Credentials which are used to identify and authorize the whole application. The following are searched (in order) to find the Application Default Credentials:
- Credentials file pointed to by the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable - Credentials provided by the Google Cloud SDK
gcloud auth application-default logincommand - Google App Engine built-in credentials
- Google Cloud Shell built-in credentials
- Google Compute Engine built-in credentials
transportFactory
HttpTransportFactory HTTP transport factory, creates the transport used to get access tokens.
GoogleCredentials
the credentials instance.
IOException
if the credentials cannot be created in the current environment.
newBuilder()
publicstaticGoogleCredentials.BuildernewBuilder()Constructors
GoogleCredentials()
protectedGoogleCredentials()Default constructor.
GoogleCredentials(AccessToken accessToken)
publicGoogleCredentials(AccessTokenaccessToken)Constructor with explicit access token.
GoogleCredentials(AccessToken accessToken, Duration refreshMargin, Duration expirationMargin)
protectedGoogleCredentials(AccessTokenaccessToken,DurationrefreshMargin,DurationexpirationMargin)Constructor with explicit access token and refresh times
Methods
createDelegated(String user)
publicGoogleCredentialscreateDelegated(Stringuser)If the credentials support domain-wide delegation, creates a copy of the identity so that it impersonates the specified user; otherwise, returns the same instance.
GoogleCredentials
GoogleCredentials with a delegated user.
createScoped(String[] scopes)
publicGoogleCredentialscreateScoped(String[]scopes)If the credentials support scopes, creates a copy of the identity with the specified scopes; otherwise, returns the same instance.
GoogleCredentials
GoogleCredentials with requested scopes.
createScoped(Collection<String> scopes)
publicGoogleCredentialscreateScoped(Collection<String>scopes)If the credentials support scopes, creates a copy of the identity with the specified scopes; otherwise, returns the same instance.
GoogleCredentials
GoogleCredentials with requested scopes.
createScoped(Collection<String> scopes, Collection<String> defaultScopes)
publicGoogleCredentialscreateScoped(Collection<String>scopes,Collection<String>defaultScopes)If the credentials support scopes, creates a copy of the identity with the specified scopes and default scopes; otherwise, returns the same instance. This is mainly used by client libraries.
GoogleCredentials
GoogleCredentials with requested scopes.
createScopedRequired()
publicbooleancreateScopedRequired()Indicates whether the credentials require scopes to be specified via a call to GoogleCredentials#createScoped before use.
boolean
Whether the credentials require scopes to be specified.
createWithCustomRetryStrategy(boolean defaultRetriesEnabled)
publicGoogleCredentialscreateWithCustomRetryStrategy(booleandefaultRetriesEnabled)If the credentials support automatic retries, creates a copy of the identity with the provided retry strategy
GoogleCredentials
GoogleCredentials with the new default retries configuration.
toBuilder()
publicGoogleCredentials.BuildertoBuilder()