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 Stringprivate GoogleCredentialsprivate booleanprivate 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 Stringstatic final String(package private) static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Class<?> (package private) final GoogleCredentialsgetDefaultCredentials(HttpTransportFactory transportFactory) Returns the Application Default Credentials.private final GoogleCredentialsgetDefaultCredentialsUnsynchronized(HttpTransportFactory transportFactory) (package private) String(package private) String(package private) StringgetProperty(String property, String def) private final File(package private) booleanprotected boolean(package private) InputStreamreadStream(File file) private booleanprivate booleanprivate GoogleCredentialsprivate GoogleCredentialsprivate final GoogleCredentialstryGetComputeCredentials(HttpTransportFactory transportFactory) private voidwarnAboutProblematicCredentials(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_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
- 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
-