Class GoogleCredential.Builder (1.35.1)

public static class GoogleCredential.Builder extends Credential.Builder

Google credential builder.

Implementation is not thread-safe.

Inheritance

java.lang.Object > com.google.api.client.auth.oauth2.Credential.Builder > GoogleCredential.Builder

Constructors

Builder()

public Builder()

Methods

addRefreshListener(CredentialRefreshListener refreshListener)

public GoogleCredential.Builder addRefreshListener(CredentialRefreshListener refreshListener)
Parameter
NameDescription
refreshListenercom.google.api.client.auth.oauth2.CredentialRefreshListener
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.addRefreshListener(com.google.api.client.auth.oauth2.CredentialRefreshListener)

build()

public GoogleCredential build()
Returns
TypeDescription
GoogleCredential
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.build()

getServiceAccountId()

public final String getServiceAccountId()

Returns the service account ID (typically an e-mail address) or null for none.

Returns
TypeDescription
String

getServiceAccountPrivateKey()

public final PrivateKey getServiceAccountPrivateKey()

Returns the private key to use with the service account flow or null for none.

Returns
TypeDescription
PrivateKey

getServiceAccountPrivateKeyId()

public final String getServiceAccountPrivateKeyId()

Beta
Returns the id of the private key to use with the service account flow or null for none.

Returns
TypeDescription
String

getServiceAccountProjectId()

public final String getServiceAccountProjectId()

Returns the service account Project ID or null for none.

Returns
TypeDescription
String

getServiceAccountScopes()

public final Collection<String> getServiceAccountScopes()

Returns a collection of OAuth scopes to use with the service account flow or null for none.

Returns
TypeDescription
Collection<String>

getServiceAccountUser()

public final String getServiceAccountUser()

Returns the email address of the user the application is trying to impersonate in the service account flow or null for none.

Returns
TypeDescription
String

setClientAuthentication(HttpExecuteInterceptor clientAuthentication)

public GoogleCredential.Builder setClientAuthentication(HttpExecuteInterceptor clientAuthentication)
Parameter
NameDescription
clientAuthenticationcom.google.api.client.http.HttpExecuteInterceptor
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setClientAuthentication(com.google.api.client.http.HttpExecuteInterceptor)

setClientSecrets(GoogleClientSecrets clientSecrets)

public GoogleCredential.Builder setClientSecrets(GoogleClientSecrets clientSecrets)

Sets the client secrets.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
clientSecretsGoogleClientSecrets
Returns
TypeDescription
GoogleCredential.Builder

setClientSecrets(String clientId, String clientSecret)

public GoogleCredential.Builder setClientSecrets(String clientId, String clientSecret)

Sets the client identifier and secret.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameters
NameDescription
clientIdString
clientSecretString
Returns
TypeDescription
GoogleCredential.Builder

setClock(Clock clock)

public GoogleCredential.Builder setClock(Clock clock)
Parameter
NameDescription
clockcom.google.api.client.util.Clock
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setClock(com.google.api.client.util.Clock)

setJsonFactory(JsonFactory jsonFactory)

public GoogleCredential.Builder setJsonFactory(JsonFactory jsonFactory)
Parameter
NameDescription
jsonFactorycom.google.api.client.json.JsonFactory
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setJsonFactory(com.google.api.client.json.JsonFactory)

setRefreshListeners(Collection<CredentialRefreshListener> refreshListeners)

public GoogleCredential.Builder setRefreshListeners(Collection<CredentialRefreshListener> refreshListeners)
Parameter
NameDescription
refreshListenersCollection<com.google.api.client.auth.oauth2.CredentialRefreshListener>
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setRefreshListeners(java.util.Collection<com.google.api.client.auth.oauth2.CredentialRefreshListener>)

setRequestInitializer(HttpRequestInitializer requestInitializer)

public GoogleCredential.Builder setRequestInitializer(HttpRequestInitializer requestInitializer)
Parameter
NameDescription
requestInitializercom.google.api.client.http.HttpRequestInitializer
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setRequestInitializer(com.google.api.client.http.HttpRequestInitializer)

setServiceAccountId(String serviceAccountId)

public GoogleCredential.Builder setServiceAccountId(String serviceAccountId)

Sets the service account ID (typically an e-mail address) or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
serviceAccountIdString
Returns
TypeDescription
GoogleCredential.Builder

setServiceAccountPrivateKey(PrivateKey serviceAccountPrivateKey)

public GoogleCredential.Builder setServiceAccountPrivateKey(PrivateKey serviceAccountPrivateKey)

Sets the private key to use with the service account flow or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
serviceAccountPrivateKeyPrivateKey
Returns
TypeDescription
GoogleCredential.Builder

setServiceAccountPrivateKeyFromP12File(File p12File)

public GoogleCredential.Builder setServiceAccountPrivateKeyFromP12File(File p12File)

Sets the private key to use with the service account flow or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
p12FileFile

p12 file object

Returns
TypeDescription
GoogleCredential.Builder
Exceptions
TypeDescription
GeneralSecurityException
IOException

setServiceAccountPrivateKeyFromP12File(InputStream p12FileInputStream)

public GoogleCredential.Builder setServiceAccountPrivateKeyFromP12File(InputStream p12FileInputStream)

Sets the private key to use with the service account flow or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
p12FileInputStreamInputStream

input stream to the p12 file. This file is closed at the end of this method in a finally block.

Returns
TypeDescription
GoogleCredential.Builder
Exceptions
TypeDescription
GeneralSecurityException
IOException

setServiceAccountPrivateKeyFromPemFile(File pemFile)

public GoogleCredential.Builder setServiceAccountPrivateKeyFromPemFile(File pemFile)

Beta
Sets the private key to use with the service account flow or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
pemFileFile

input stream to the PEM file (closed at the end of this method in a finally block)

Returns
TypeDescription
GoogleCredential.Builder
Exceptions
TypeDescription
GeneralSecurityException
IOException

setServiceAccountPrivateKeyId(String serviceAccountPrivateKeyId)

public GoogleCredential.Builder setServiceAccountPrivateKeyId(String serviceAccountPrivateKeyId)

Beta
Sets the id of the private key to use with the service account flow or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
serviceAccountPrivateKeyIdString
Returns
TypeDescription
GoogleCredential.Builder

setServiceAccountProjectId(String serviceAccountProjectId)

public GoogleCredential.Builder setServiceAccountProjectId(String serviceAccountProjectId)

Sets the service account Project ID or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
serviceAccountProjectIdString
Returns
TypeDescription
GoogleCredential.Builder

setServiceAccountScopes(Collection<String> serviceAccountScopes)

public GoogleCredential.Builder setServiceAccountScopes(Collection<String> serviceAccountScopes)

Sets the space-separated OAuth scopes to use with the service account flow or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
serviceAccountScopesCollection<String>

collection of scopes to be joined by a space separator (or a single value containing multiple space-separated scopes)

Returns
TypeDescription
GoogleCredential.Builder

setServiceAccountUser(String serviceAccountUser)

public GoogleCredential.Builder setServiceAccountUser(String serviceAccountUser)

Sets the email address of the user the application is trying to impersonate in the service account flow or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
serviceAccountUserString
Returns
TypeDescription
GoogleCredential.Builder

setTokenServerEncodedUrl(String tokenServerEncodedUrl)

public GoogleCredential.Builder setTokenServerEncodedUrl(String tokenServerEncodedUrl)
Parameter
NameDescription
tokenServerEncodedUrlString
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setTokenServerEncodedUrl(java.lang.String)

setTokenServerUrl(GenericUrl tokenServerUrl)

public GoogleCredential.Builder setTokenServerUrl(GenericUrl tokenServerUrl)
Parameter
NameDescription
tokenServerUrlcom.google.api.client.http.GenericUrl
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setTokenServerUrl(com.google.api.client.http.GenericUrl)

setTransport(HttpTransport transport)

public GoogleCredential.Builder setTransport(HttpTransport transport)
Parameter
NameDescription
transportcom.google.api.client.http.HttpTransport
Returns
TypeDescription
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setTransport(com.google.api.client.http.HttpTransport)