public class ServiceAccountCredentials extends GoogleCredentials
By default uses a JSON Web Token (JWT) to fetch access tokens.
| Constructor and Description |
|---|
ServiceAccountCredentials(String clientId,
String clientEmail,
PrivateKey privateKey,
String privateKeyId,
Collection<String> scopes)
Constructor with minimum identifying information.
|
ServiceAccountCredentials(String clientId,
String clientEmail,
PrivateKey privateKey,
String privateKeyId,
Collection<String> scopes,
com.google.api.client.http.HttpTransport transport)
Constructor with minimum identifying information and custom HTTP transport.
|
| Modifier and Type | Method and Description |
|---|---|
GoogleCredentials |
createScoped(Collection<String> newScopes)
Clones the service account with the specified scopes.
|
boolean |
createScopedRequired()
Returns whther the scopes are empty, meaning createScoped must be called before use.
|
static ServiceAccountCredentials |
fromPkcs8(String clientId,
String clientEmail,
String privateKeyPkcs8,
String privateKeyId,
Collection<String> scopes)
Factory with miniumum identifying information using PKCS#8 for the private key.
|
static ServiceAccountCredentials |
fromPkcs8(String clientId,
String clientEmail,
String privateKeyPkcs8,
String privateKeyId,
Collection<String> scopes,
com.google.api.client.http.HttpTransport transport)
Factory with miniumum identifying information and custom transport using PKCS#8 for the
private key.
|
String |
getClientEmail() |
String |
getClientId() |
PrivateKey |
getPrivateKey() |
String |
getPrivateKeyId() |
Collection<String> |
getScopes() |
AccessToken |
refreshAccessToken()
Refreshes the OAuth2 access token by getting a new access token using a JSON Web Token (JWT).
|
fromStream, fromStream, getApplicationDefault, getApplicationDefaultgetAuthenticationType, getRequestMetadata, hasRequestMetadata, hasRequestMetadataOnly, refreshgetRequestMetadatapublic ServiceAccountCredentials(String clientId, String clientEmail, PrivateKey privateKey, String privateKeyId, Collection<String> scopes)
clientId - Client ID of the service account from the console. May be null.clientEmail - Client email address of the service account from the console.privateKey - RSA private key object for the service account.privateKeyId - Private key identifier for the service account. May be null.scopes - Scope strings for the APIs to be called. May be null or an empty collection,
which results in a credential that must have createScoped called before use.public ServiceAccountCredentials(String clientId, String clientEmail, PrivateKey privateKey, String privateKeyId, Collection<String> scopes, com.google.api.client.http.HttpTransport transport)
clientId - Client ID of the service account from the console. May be null.clientEmail - Client email address of the service account from the console.privateKey - RSA private key object for the service account.privateKeyId - Private key identifier for the service account. May be null.scopes - Scope strings for the APIs to be called. May be null or an empty collection,
which results in a credential that must have createScoped called before use.transport - HTTP object used to get access tokens.public static ServiceAccountCredentials fromPkcs8(String clientId, String clientEmail, String privateKeyPkcs8, String privateKeyId, Collection<String> scopes) throws IOException
clientId - Client ID of the service account from the console. May be null.clientEmail - Client email address of the service account from the console.privateKeyPkcs8 - RSA private key object for the service account in PKCS#8 format.privateKeyId - Private key identifier for the service account. May be null.scopes - Scope strings for the APIs to be called. May be null or an emptt collection,
which results in a credential that must have createScoped called before use.IOExceptionpublic static ServiceAccountCredentials fromPkcs8(String clientId, String clientEmail, String privateKeyPkcs8, String privateKeyId, Collection<String> scopes, com.google.api.client.http.HttpTransport transport) throws IOException
clientId - Client ID of the service account from the console. May be null.clientEmail - Client email address of the service account from the console.privateKeyPkcs8 - RSA private key object for the service account in PKCS#8 format.privateKeyId - Private key identifier for the service account. May be null.scopes - Scope strings for the APIs to be called. May be null or an emptt collection,
which results in a credential that must have createScoped called before use.transport - HTTP object used to get access tokens.IOExceptionpublic AccessToken refreshAccessToken() throws IOException
refreshAccessToken in class OAuth2CredentialsIOExceptionpublic boolean createScopedRequired()
createScopedRequired in class GoogleCredentialspublic GoogleCredentials createScoped(Collection<String> newScopes)
Should be called before use for instances with empty scopes.
createScoped in class GoogleCredentialspublic final String getClientId()
public final String getClientEmail()
public final PrivateKey getPrivateKey()
public final String getPrivateKeyId()
public final Collection<String> getScopes()
Copyright © 2015 Google. All rights reserved.