public class UserCredentials extends GoogleCredentials implements QuotaProjectIdProvider, IdTokenProviderOAuth2 Credentials representing a user's identity and consent.
Static Methods
fromStream(InputStream credentialsStream)
public static UserCredentials fromStream(InputStream credentialsStream)Returns credentials defined by a JSON file stream using the format supported by the Cloud SDK.
| Name | Description |
| credentialsStream | InputStreamthe stream with the credential definition. |
| Type | Description |
| UserCredentials | the credential defined by the credentialsStream. |
| Type | Description |
| IOException | if the credential cannot be created from the stream. |
fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory)
public static UserCredentials fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory)Returns credentials defined by a JSON file stream using the format supported by the Cloud SDK.
| Name | Description |
| credentialsStream | InputStreamthe stream with the credential definition. |
| transportFactory | HttpTransportFactoryHTTP transport factory, creates the transport used to get access tokens. |
| Type | Description |
| UserCredentials | the credential defined by the credentialsStream. |
| Type | Description |
| IOException | if the credential cannot be created from the stream. |
newBuilder()
public static UserCredentials.Builder newBuilder()| Type | Description |
| UserCredentials.Builder |
Methods
equals(Object obj)
public boolean equals(Object obj)| Name | Description |
| obj | Object |
| Type | Description |
| boolean |
getAdditionalHeaders()
protected Map<String,List<String>> getAdditionalHeaders()Provide additional headers to return as request metadata.
| Type | Description |
| Map<String,List<String>> |
getClientId()
public final String getClientId()Returns client ID of the credential from the console.
| Type | Description |
| String | client ID |
getClientSecret()
public final String getClientSecret()Returns client secret of the credential from the console.
| Type | Description |
| String | client secret |
getQuotaProjectId()
public String getQuotaProjectId()| Type | Description |
| String |
getRefreshToken()
public final String getRefreshToken()Returns the refresh token resulting from a OAuth2 consent flow.
| Type | Description |
| String | refresh token |
hashCode()
public int hashCode()| Type | Description |
| int |
idTokenWithAudience(String targetAudience, List<IdTokenProvider.Option> options)
public IdToken idTokenWithAudience(String targetAudience, List<IdTokenProvider.Option> options)Returns a Google ID Token from the refresh token response.
| Name | Description |
| targetAudience | StringThis can't be used for UserCredentials. |
| options | List<Option>list of Credential specific options for the token. Currently unused for UserCredentials. |
| Type | Description |
| IdToken | IdToken object which includes the raw id_token, expiration and audience |
| Type | Description |
| IOException | if the attempt to get an IdToken failed |
refreshAccessToken()
public AccessToken refreshAccessToken()Refreshes the OAuth2 access token by getting a new access token from the refresh token
| Type | Description |
| AccessToken |
| Type | Description |
| IOException |
save(String filePath)
public void save(String filePath)Saves the end user credentials into the given file path.
| Name | Description |
| filePath | StringPath to file where to store the credentials |
| Type | Description |
| IOException | An error storing the credentials. |
toBuilder()
public UserCredentials.Builder toBuilder()| Type | Description |
| UserCredentials.Builder |
toString()
public String toString()| Type | Description |
| String |