public class OAuth2Credentials extends Credentials
| Modifier and Type | Class and Description |
|---|---|
static class |
OAuth2Credentials.Builder |
static interface |
OAuth2Credentials.CredentialsChangedListener
Listener for changes to credentials.
|
| Modifier | Constructor and Description |
|---|---|
protected |
OAuth2Credentials()
Default constructor.
|
|
OAuth2Credentials(AccessToken accessToken)
Deprecated.
Use
create(AccessToken) instead. This constructor will either be deleted
or made private in a later version. |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(OAuth2Credentials.CredentialsChangedListener listener)
Adds a listener that is notified when the Credentials data changes.
|
static OAuth2Credentials |
create(AccessToken accessToken)
Returns the credentials instance from the given access token.
|
boolean |
equals(Object obj) |
AccessToken |
getAccessToken() |
String |
getAuthenticationType() |
protected static <T> T |
getFromServiceLoader(Class<? extends T> clazz,
T defaultInstance) |
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.
|
void |
getRequestMetadata(URI uri,
Executor executor,
RequestMetadataCallback callback) |
protected Map<String,List<String>> |
getRequestMetadataInternal() |
int |
hashCode() |
boolean |
hasRequestMetadata() |
boolean |
hasRequestMetadataOnly() |
static OAuth2Credentials.Builder |
newBuilder() |
protected static <T> T |
newInstance(String className) |
static OAuth2Credentials |
of(AccessToken accessToken)
Deprecated.
Use
create(AccessToken) instead. This method will be deleted in a later
version. |
void |
refresh()
Refresh the token by discarding the cached token and metadata and requesting the new ones.
|
AccessToken |
refreshAccessToken()
Method to refresh the access token according to the specific type of credentials.
|
void |
removeChangeListener(OAuth2Credentials.CredentialsChangedListener listener)
Removes a listener that was added previously.
|
OAuth2Credentials.Builder |
toBuilder() |
String |
toString() |
blockingGetToCallback, getRequestMetadataprotected OAuth2Credentials()
@Deprecated public OAuth2Credentials(AccessToken accessToken)
create(AccessToken) instead. This constructor will either be deleted
or made private in a later version.accessToken - Initial or temporary access token.@Deprecated public static OAuth2Credentials of(AccessToken accessToken)
create(AccessToken) instead. This method will be deleted in a later
version.accessToken - the access tokenpublic static OAuth2Credentials create(AccessToken accessToken)
accessToken - the access tokenpublic String getAuthenticationType()
getAuthenticationType in class Credentialspublic boolean hasRequestMetadata()
hasRequestMetadata in class Credentialspublic boolean hasRequestMetadataOnly()
hasRequestMetadataOnly in class Credentialspublic final AccessToken getAccessToken()
public void getRequestMetadata(URI uri, Executor executor, RequestMetadataCallback callback)
getRequestMetadata in class Credentialspublic 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.public final void removeChangeListener(OAuth2Credentials.CredentialsChangedListener listener)
listener - The listener to be removed.protected static <T> T newInstance(String className) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionprotected static <T> T getFromServiceLoader(Class<? extends T> clazz, T defaultInstance)
public static OAuth2Credentials.Builder newBuilder()
public OAuth2Credentials.Builder toBuilder()
Copyright © 2017 Google. All rights reserved.