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
Inherited Members
com.google.api.client.auth.oauth2.Credential.Builder.addRefreshListener(com.google.api.client.auth.oauth2.CredentialRefreshListener)
com.google.api.client.auth.oauth2.Credential.Builder.build()
com.google.api.client.auth.oauth2.Credential.Builder.getClientAuthentication()
com.google.api.client.auth.oauth2.Credential.Builder.getClock()
com.google.api.client.auth.oauth2.Credential.Builder.getJsonFactory()
com.google.api.client.auth.oauth2.Credential.Builder.getMethod()
com.google.api.client.auth.oauth2.Credential.Builder.getRefreshListeners()
com.google.api.client.auth.oauth2.Credential.Builder.getRequestInitializer()
com.google.api.client.auth.oauth2.Credential.Builder.getTokenServerUrl()
com.google.api.client.auth.oauth2.Credential.Builder.getTransport()
com.google.api.client.auth.oauth2.Credential.Builder.setClientAuthentication(com.google.api.client.http.HttpExecuteInterceptor)
com.google.api.client.auth.oauth2.Credential.Builder.setClock(com.google.api.client.util.Clock)
com.google.api.client.auth.oauth2.Credential.Builder.setJsonFactory(com.google.api.client.json.JsonFactory)
com.google.api.client.auth.oauth2.Credential.Builder.setRefreshListeners(java.util.Collection<com.google.api.client.auth.oauth2.CredentialRefreshListener>)
com.google.api.client.auth.oauth2.Credential.Builder.setRequestInitializer(com.google.api.client.http.HttpRequestInitializer)
com.google.api.client.auth.oauth2.Credential.Builder.setTokenServerEncodedUrl(java.lang.String)
com.google.api.client.auth.oauth2.Credential.Builder.setTokenServerUrl(com.google.api.client.http.GenericUrl)
com.google.api.client.auth.oauth2.Credential.Builder.setTransport(com.google.api.client.http.HttpTransport)
Constructors
Builder()
Methods
addRefreshListener(CredentialRefreshListener refreshListener)
public GoogleCredential.Builder addRefreshListener(CredentialRefreshListener refreshListener)
Parameter
Name | Description |
refreshListener | com.google.api.client.auth.oauth2.CredentialRefreshListener
|
Returns
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.addRefreshListener(com.google.api.client.auth.oauth2.CredentialRefreshListener)
build()
public GoogleCredential build()
Returns
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
getServiceAccountPrivateKey()
public final PrivateKey getServiceAccountPrivateKey()
Returns the private key to use with the service account flow or null
for none.
Returns
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
getServiceAccountProjectId()
public final String getServiceAccountProjectId()
Returns the service account Project ID or null
for none.
Returns
getServiceAccountScopes()
public final Collection<String> getServiceAccountScopes()
Returns a collection of OAuth scopes to use with the service account flow or null
for
none.
Returns
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
setClientAuthentication(HttpExecuteInterceptor clientAuthentication)
public GoogleCredential.Builder setClientAuthentication(HttpExecuteInterceptor clientAuthentication)
Parameter
Name | Description |
clientAuthentication | com.google.api.client.http.HttpExecuteInterceptor
|
Returns
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
Returns
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
Returns
setClock(Clock clock)
public GoogleCredential.Builder setClock(Clock clock)
Parameter
Name | Description |
clock | com.google.api.client.util.Clock
|
Returns
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
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
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
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
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
Returns
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
Exceptions
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
Exceptions
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
Exceptions
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
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
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
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
setTokenServerEncodedUrl(String tokenServerEncodedUrl)
public GoogleCredential.Builder setTokenServerEncodedUrl(String tokenServerEncodedUrl)
Parameter
Name | Description |
tokenServerEncodedUrl | String
|
Returns
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
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
Overrides
com.google.api.client.auth.oauth2.Credential.Builder.setTransport(com.google.api.client.http.HttpTransport)