public class UserCredentials extends GoogleCredentials implements IdTokenProvider
Modifier and Type | Class and Description |
---|---|
static class |
UserCredentials.Builder |
OAuth2Credentials.CredentialsChangedListener
IdTokenProvider.Option
quotaProjectId
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
static UserCredentials |
fromStream(InputStream credentialsStream)
Returns credentials defined by a JSON file stream using the format supported by the Cloud SDK.
|
static UserCredentials |
fromStream(InputStream credentialsStream,
HttpTransportFactory transportFactory)
Returns credentials defined by a JSON file stream using the format supported by the Cloud SDK.
|
String |
getClientId()
Returns client ID of the credential from the console.
|
String |
getClientSecret()
Returns client secret of the credential from the console.
|
String |
getRefreshToken()
Returns the refresh token resulting from a OAuth2 consent flow.
|
int |
hashCode() |
IdToken |
idTokenWithAudience(String targetAudience,
List<IdTokenProvider.Option> options)
Returns a Google ID Token from the refresh token response.
|
static UserCredentials.Builder |
newBuilder() |
AccessToken |
refreshAccessToken()
Refreshes the OAuth2 access token by getting a new access token from the refresh token
|
void |
save(String filePath)
Saves the end user credentials into the given file path.
|
UserCredentials.Builder |
toBuilder() |
String |
toString() |
create, createDelegated, createScoped, createScoped, createScoped, createScopedRequired, createWithCustomRetryStrategy, createWithQuotaProject, getAdditionalHeaders, getApplicationDefault, getApplicationDefault, getQuotaProjectId
addChangeListener, getAccessToken, getAuthenticationType, getFromServiceLoader, getRequestMetadata, getRequestMetadata, getRequestMetadataInternal, hasRequestMetadata, hasRequestMetadataOnly, newInstance, refresh, refreshIfExpired, removeChangeListener
blockingGetToCallback, getRequestMetadata
public static UserCredentials fromStream(InputStream credentialsStream) throws IOException
credentialsStream
- the stream with the credential definition.IOException
- if the credential cannot be created from the stream.public static UserCredentials fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory) throws IOException
credentialsStream
- the stream with the credential definition.transportFactory
- HTTP transport factory, creates the transport used to get access
tokens.IOException
- if the credential cannot be created from the stream.public AccessToken refreshAccessToken() throws IOException
refreshAccessToken
in class OAuth2Credentials
IOException
public IdToken idTokenWithAudience(String targetAudience, List<IdTokenProvider.Option> options) throws IOException
idTokenWithAudience
in interface IdTokenProvider
targetAudience
- This can't be used for UserCredentials.options
- list of Credential specific options for the token. Currently unused for
UserCredentials.IOException
- if the attempt to get an IdToken failedpublic final String getClientId()
public final String getClientSecret()
public final String getRefreshToken()
public void save(String filePath) throws IOException
filePath
- Path to file where to store the credentialsIOException
- An error storing the credentials.public int hashCode()
hashCode
in class OAuth2Credentials
public String toString()
toString
in class OAuth2Credentials
public boolean equals(Object obj)
equals
in class OAuth2Credentials
public static UserCredentials.Builder newBuilder()
public UserCredentials.Builder toBuilder()
toBuilder
in class GoogleCredentials
Copyright © 2023 Google. All rights reserved.