Class GoogleCredential.Builder (2.5.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
Name Description
refreshListener com.google.api.client.auth.oauth2.CredentialRefreshListener
Returns
Type Description
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.addRefreshListener(com.google.api.client.auth.oauth2.CredentialRefreshListener)

build()

public GoogleCredential build()
Returns
Type Description
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
Type Description
String

getServiceAccountPrivateKey()

public final PrivateKey getServiceAccountPrivateKey()

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

Returns
Type Description
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
Type Description
String

getServiceAccountProjectId()

public final String getServiceAccountProjectId()

Returns the service account Project ID or null for none.

Returns
Type Description
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
Type Description
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
Type Description
String

setClientAuthentication(HttpExecuteInterceptor clientAuthentication)

public GoogleCredential.Builder setClientAuthentication(HttpExecuteInterceptor clientAuthentication)
Parameter
Name Description
clientAuthentication com.google.api.client.http.HttpExecuteInterceptor
Returns
Type Description
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
Name Description
clientSecrets GoogleClientSecrets
Returns
Type Description
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
Name Description
clientId String
clientSecret String
Returns
Type Description
GoogleCredential.Builder

setClock(Clock clock)

public GoogleCredential.Builder setClock(Clock clock)
Parameter
Name Description
clock com.google.api.client.util.Clock
Returns
Type Description
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
Name Description
jsonFactory com.google.api.client.json.JsonFactory
Returns
Type Description
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
Name Description
refreshListeners Collection<com.google.api.client.auth.oauth2.CredentialRefreshListener>
Returns
Type Description
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
Name Description
requestInitializer com.google.api.client.http.HttpRequestInitializer
Returns
Type Description
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
Name Description
serviceAccountId String
Returns
Type Description
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
Name Description
serviceAccountPrivateKey PrivateKey
Returns
Type Description
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
Name Description
p12File File

p12 file object

Returns
Type Description
GoogleCredential.Builder
Exceptions
Type Description
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
Name Description
p12FileInputStream InputStream

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

Returns
Type Description
GoogleCredential.Builder
Exceptions
Type Description
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
Name Description
pemFile File

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

Returns
Type Description
GoogleCredential.Builder
Exceptions
Type Description
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
Name Description
serviceAccountPrivateKeyId String
Returns
Type Description
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
Name Description
serviceAccountProjectId String
Returns
Type Description
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
Name Description
serviceAccountScopes Collection<String>

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

Returns
Type Description
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
Name Description
serviceAccountUser String
Returns
Type Description
GoogleCredential.Builder

setTokenServerEncodedUrl(String tokenServerEncodedUrl)

public GoogleCredential.Builder setTokenServerEncodedUrl(String tokenServerEncodedUrl)
Parameter
Name Description
tokenServerEncodedUrl String
Returns
Type Description
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
Name Description
tokenServerUrl com.google.api.client.http.GenericUrl
Returns
Type Description
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
Name Description
transport com.google.api.client.http.HttpTransport
Returns
Type Description
GoogleCredential.Builder
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setTransport(com.google.api.client.http.HttpTransport)