public class CredentialFactory extends 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<String> |
DEFAULT_SCOPES |
Constructor and Description |
---|
CredentialFactory(CredentialOptions options) |
Modifier and Type | Method and Description |
---|---|
com.google.api.client.auth.oauth2.Credential |
getCredential(List<String> scopes)
Get the credential as configured.
|
static 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(List<String> scopes,
com.google.api.client.http.HttpTransport transport)
Initializes OAuth2 credential from a private keyfile, as described in OAuth2
Service Accounts.
|
public static final com.google.common.collect.ImmutableList<String> DEFAULT_SCOPES
public CredentialFactory(CredentialOptions options)
public static com.google.api.client.auth.oauth2.Credential getCredentialFromMetadataServiceAccount() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public com.google.api.client.auth.oauth2.Credential getCredentialFromPrivateKeyServiceAccount(List<String> scopes, com.google.api.client.http.HttpTransport transport) throws IOException, GeneralSecurityException
scopes
- List of well-formed desired scopes to use with the credential.transport
- The HttpTransport used for authorizationIOException
GeneralSecurityException
public com.google.api.client.auth.oauth2.Credential getCredential(List<String> scopes) throws IOException, GeneralSecurityException
The following is the order in which properties are applied to create the Credential:
IllegalStateException
- if none of the above conditions are met and a Credential cannot
be createdIOException
GeneralSecurityException
Copyright © 2024. All rights reserved.