public class OAuth2Credentials extends Credentials
| Modifier and Type | Class and Description |
|---|---|
static interface |
OAuth2Credentials.CredentialsChangedListener
Listener for changes to credentials.
|
| Modifier | Constructor and Description |
|---|---|
protected |
OAuth2Credentials()
Default constructor.
|
|
OAuth2Credentials(AccessToken accessToken)
Constructor with explicit access token.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(OAuth2Credentials.CredentialsChangedListener listener)
Adds a listener that is notified when the Credentials data changes.
|
AccessToken |
getAccessToken() |
String |
getAuthenticationType() |
Map<String,List<String>> |
getRequestMetadata(URI uri)
Provide the request metadata by ensuring there is a current access token and providing it
as an authorization bearer token.
|
boolean |
hasRequestMetadata() |
boolean |
hasRequestMetadataOnly() |
void |
refresh()
Refresh the token by discarding the cached token and metadata.
|
AccessToken |
refreshAccessToken()
Method to refresh the access token according to the specific type of credentials.
|
getRequestMetadataprotected OAuth2Credentials()
public OAuth2Credentials(AccessToken accessToken)
accessToken - Initial or temporary access token.public String getAuthenticationType()
getAuthenticationType in class Credentialspublic boolean hasRequestMetadata()
hasRequestMetadata in class Credentialspublic boolean hasRequestMetadataOnly()
hasRequestMetadataOnly in class Credentialspublic final AccessToken getAccessToken()
public Map<String,List<String>> getRequestMetadata(URI uri) throws IOException
getRequestMetadata in class CredentialsIOExceptionpublic void refresh()
throws IOException
refresh in class CredentialsIOExceptionpublic AccessToken refreshAccessToken() throws IOException
IOException - from derived implementationspublic final void addChangeListener(OAuth2Credentials.CredentialsChangedListener listener)
This is called when token content changes, such as when the access token is refreshed. This is typically used by code caching the access token.
listener - The listener to be added.Copyright © 2015 Google. All rights reserved.