public class GoogleCredentials extends OAuth2Credentials
OAuth2Credentials.CredentialsChangedListener| Modifier | Constructor and Description |
|---|---|
protected |
GoogleCredentials()
Default constructor.
|
|
GoogleCredentials(AccessToken accessToken)
Constructor with explicit access token.
|
| Modifier and Type | Method and Description |
|---|---|
GoogleCredentials |
createDelegated(String user)
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 |
createScoped(Collection<String> scopes)
If the credentials support scopes, creates a copy of the the identity with the specified
scopes; otherwise, returns the same instance.
|
boolean |
createScopedRequired()
Indicates whether the credentials require scopes to be specified via a call to
{link GoogleCredentials#createScoped} before use.
|
static GoogleCredentials |
fromStream(InputStream credentialsStream)
Returns credentials defined by a JSON file stream.
|
static GoogleCredentials |
fromStream(InputStream credentialsStream,
HttpTransportFactory transportFactory)
Returns credentials defined by a JSON file stream.
|
static GoogleCredentials |
getApplicationDefault()
Returns the Application Default Credentials.
|
static GoogleCredentials |
getApplicationDefault(HttpTransportFactory transportFactory)
Returns the Application Default Credentials.
|
addChangeListener, equals, getAccessToken, getAuthenticationType, getFromServiceLoader, getRequestMetadata, getRequestMetadata, hashCode, hasRequestMetadata, hasRequestMetadataOnly, newInstance, refresh, refreshAccessToken, toString, toStringHelperblockingGetToCallback, getRequestMetadataprotected GoogleCredentials()
public GoogleCredentials(AccessToken accessToken)
accessToken - Initial or temporary access token.public static GoogleCredentials getApplicationDefault() throws IOException
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:
GOOGLE_APPLICATION_CREDENTIALS environment
variablegcloud auth application-default login commandIOException - if the credentials cannot be created in the current environment.public static GoogleCredentials getApplicationDefault(HttpTransportFactory transportFactory) throws IOException
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:
GOOGLE_APPLICATION_CREDENTIALS environment
variablegcloud auth application-default login commandtransportFactory - HTTP transport factory, creates the transport used to get access
tokens.IOException - if the credentials cannot be created in the current environment.public static GoogleCredentials fromStream(InputStream credentialsStream) throws IOException
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.
credentialsStream - the stream with the credential definition.IOException - if the credential cannot be created from the stream.public static GoogleCredentials fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory) throws IOException
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.
credentialsStream - the stream with the credential definition.transportFactory - HTTP transport factory, creates the transport used to get access
tokens.IOException - if the credential cannot be created from the stream.public boolean createScopedRequired()
public GoogleCredentials createScoped(Collection<String> scopes)
public GoogleCredentials createDelegated(String user)
Copyright © 2017 Google. All rights reserved.