public class CredentialFactory
extends java.lang.Object
Credential
from various sources.Modifier and Type | Class and Description |
---|---|
static class |
CredentialFactory.ComputeCredentialWithRetry
A subclass of ComputeCredential that properly sets request initializers.
|
static class |
CredentialFactory.CredentialHttpRetryInitializer
Simple HttpRequestInitializer that retries requests that result in 5XX response codes and IO
Exceptions with an exponential backoff.
|
static class |
CredentialFactory.GoogleCredentialWithRetry
A subclass of
GoogleCredential that properly wires specified HttpRequestInitializer through the @{link Credential#executeRefreshToken} override. |
Modifier and Type | Field and Description |
---|---|
static com.google.common.collect.ImmutableList<java.lang.String> |
GCS_SCOPES |
Constructor and Description |
---|
CredentialFactory() |
Modifier and Type | Method and Description |
---|---|
com.google.api.client.auth.oauth2.Credential |
getApplicationDefaultCredentials(java.util.List<java.lang.String> scopes,
com.google.api.client.http.HttpTransport transport)
Get Google Application Default Credentials as described in Google Application Default Credentials
|
com.google.api.client.auth.oauth2.Credential |
getCredentialFromFileCredentialStoreForInstalledApp(java.lang.String clientId,
java.lang.String clientSecret,
java.lang.String filePath,
java.util.List<java.lang.String> scopes,
com.google.api.client.http.HttpTransport transport)
Initialized OAuth2 credential for the "installed application" flow; where the credential
typically represents an actual end user (instead of a service account), and is stored as a
refresh token in a local FileCredentialStore.
|
com.google.api.client.auth.oauth2.Credential |
getCredentialFromJsonKeyFile(java.lang.String serviceAccountJsonKeyFile,
java.util.List<java.lang.String> scopes,
com.google.api.client.http.HttpTransport transport)
Get credentials listed in a JSON file.
|
com.google.api.client.auth.oauth2.Credential |
getCredentialFromMetadataServiceAccount()
Initializes OAuth2 credential using preconfigured ServiceAccount settings on the local GCE VM.
|
com.google.api.client.auth.oauth2.Credential |
getCredentialFromPrivateKeyServiceAccount(java.lang.String serviceAccountEmail,
java.lang.String privateKeyFile,
java.util.List<java.lang.String> scopes,
com.google.api.client.http.HttpTransport transport)
Initializes OAuth2 credential from a private keyfile, as described in OAuth2
Service Accounts.
|
com.google.api.client.auth.oauth2.Credential |
getCredentialsFromSAParameters(java.lang.String privateKeyId,
java.lang.String privateKeyPem,
java.lang.String serviceAccountEmail,
java.util.List<java.lang.String> scopes,
com.google.api.client.http.HttpTransport transport) |
public static final com.google.common.collect.ImmutableList<java.lang.String> GCS_SCOPES
public com.google.api.client.auth.oauth2.Credential getCredentialFromMetadataServiceAccount() throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
public com.google.api.client.auth.oauth2.Credential getCredentialFromPrivateKeyServiceAccount(java.lang.String serviceAccountEmail, java.lang.String privateKeyFile, java.util.List<java.lang.String> scopes, com.google.api.client.http.HttpTransport transport) throws java.io.IOException, java.security.GeneralSecurityException
serviceAccountEmail
- Email address of the service account associated with the keyfile.privateKeyFile
- Full local path to private keyfile.scopes
- List of well-formed desired scopes to use with the credential.transport
- The HttpTransport used for authorizationjava.io.IOException
java.security.GeneralSecurityException
public com.google.api.client.auth.oauth2.Credential getCredentialFromJsonKeyFile(java.lang.String serviceAccountJsonKeyFile, java.util.List<java.lang.String> scopes, com.google.api.client.http.HttpTransport transport) throws java.io.IOException, java.security.GeneralSecurityException
serviceAccountJsonKeyFile
- A file path pointing to a JSON file containing credentials.scopes
- The OAuth scopes that the credential should be valid for.transport
- The HttpTransport used for authorizationjava.io.IOException
java.security.GeneralSecurityException
public com.google.api.client.auth.oauth2.Credential getCredentialsFromSAParameters(java.lang.String privateKeyId, java.lang.String privateKeyPem, java.lang.String serviceAccountEmail, java.util.List<java.lang.String> scopes, com.google.api.client.http.HttpTransport transport) throws java.io.IOException
java.io.IOException
public com.google.api.client.auth.oauth2.Credential getCredentialFromFileCredentialStoreForInstalledApp(java.lang.String clientId, java.lang.String clientSecret, java.lang.String filePath, java.util.List<java.lang.String> scopes, com.google.api.client.http.HttpTransport transport) throws java.io.IOException, java.security.GeneralSecurityException
clientId
- OAuth2 client ID identifying the 'installed app'clientSecret
- OAuth2 client secretfilePath
- full path to a ".json" file for storing the credentialscopes
- list of well-formed scopes desired in the credentialtransport
- The HttpTransport used for authorizationfilePath
.java.io.IOException
- on IO errorjava.security.GeneralSecurityException
public com.google.api.client.auth.oauth2.Credential getApplicationDefaultCredentials(java.util.List<java.lang.String> scopes, com.google.api.client.http.HttpTransport transport) throws java.io.IOException, java.security.GeneralSecurityException
scopes
- The OAuth scopes that the credential should be valid for.java.io.IOException
java.security.GeneralSecurityException
Copyright © 2019. All rights reserved.