Package com.google.auth.oauth2
Class DefaultCredentialsProvider
java.lang.Object
com.google.auth.oauth2.DefaultCredentialsProvider
Provides the Application Default Credential from the environment.
An instance represents the per-process state used to get and cache the credential and allows overriding the state and environment for testing purposes.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
private GoogleCredentials
private boolean
private boolean
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final DefaultCredentialsProvider
(package private) static final String
(package private) static final String
(package private) static final Logger
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
static final String
(package private) static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Class
<?> (package private) final GoogleCredentials
getDefaultCredentials
(HttpTransportFactory transportFactory) Returns the Application Default Credentials.private final GoogleCredentials
getDefaultCredentialsUnsynchronized
(HttpTransportFactory transportFactory) (package private) String
(package private) String
(package private) String
getProperty
(String property, String def) private final File
(package private) boolean
protected boolean
(package private) InputStream
readStream
(File file) private boolean
private boolean
private GoogleCredentials
private GoogleCredentials
private final GoogleCredentials
tryGetComputeCredentials
(HttpTransportFactory transportFactory) private void
warnAboutProblematicCredentials
(GoogleCredentials credentials)
-
Field Details
-
DEFAULT
-
CREDENTIAL_ENV_VAR
- See Also:
-
QUOTA_PROJECT_ENV_VAR
- See Also:
-
WELL_KNOWN_CREDENTIALS_FILE
- See Also:
-
CLOUDSDK_CONFIG_DIRECTORY
- See Also:
-
APP_ENGINE_SIGNAL_CLASS
- See Also:
-
CLOUD_SHELL_ENV_VAR
- See Also:
-
SKIP_APP_ENGINE_ENV_VAR
- See Also:
-
SPECIFICATION_VERSION
-
GAE_RUNTIME_VERSION
-
RUNTIME_JETTY_LOGGER
-
LOGGER
-
NO_GCE_CHECK_ENV_VAR
- See Also:
-
GCE_METADATA_HOST_ENV_VAR
- See Also:
-
CLOUDSDK_CLIENT_ID
- See Also:
-
CLOUDSDK_CREDENTIALS_WARNING
- See Also:
-
CLOUDSDK_MISSING_CREDENTIALS
- See Also:
-
SUPPRESS_GCLOUD_CREDS_WARNING_ENV_VAR
- See Also:
-
cachedCredentials
-
checkedAppEngine
private boolean checkedAppEngine -
checkedComputeEngine
private boolean checkedComputeEngine
-
-
Constructor Details
-
DefaultCredentialsProvider
DefaultCredentialsProvider()
-
-
Method Details
-
getDefaultCredentials
final GoogleCredentials getDefaultCredentials(HttpTransportFactory transportFactory) throws IOException 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_CREDENTIALS
environment variable - Credentials provided by the Google Cloud SDK
gcloud auth application-default login
command - Google App Engine built-in credentials
- Google Cloud Shell built-in credentials
- Google Compute Engine built-in credentials
- Parameters:
transportFactory
- HTTP transport factory, creates the transport used to get access tokens.- Returns:
- the credentials instance.
- Throws:
IOException
- if the credentials cannot be created in the current environment.
- Credentials file pointed to by the
-
getDefaultCredentialsUnsynchronized
private final GoogleCredentials getDefaultCredentialsUnsynchronized(HttpTransportFactory transportFactory) throws IOException - Throws:
IOException
-
getWellKnownCredentialsFile
-
warnAboutProblematicCredentials
-
runningOnAppEngine
private boolean runningOnAppEngine() -
tryGetCloudShellCredentials
-
tryGetAppEngineCredential
- Throws:
IOException
-
tryGetComputeCredentials
-
skipAppEngineCredentialsCheck
private boolean skipAppEngineCredentialsCheck() -
isOnGAEStandard7
protected boolean isOnGAEStandard7() -
getOsName
String getOsName() -
forName
- Throws:
ClassNotFoundException
-
getEnv
-
getProperty
-
isFile
-
readStream
- Throws:
FileNotFoundException
-