A - the service provider's API typepublic class OAuth2Connection<A> extends AbstractConnection<A>
OAuth2ConnectionFactory should be favored to encapsulate details specific to an OAuth2-based provider.OAuth2ConnectionFactory,
Serialized Form| Constructor and Description |
|---|
OAuth2Connection(ConnectionData data,
OAuth2ServiceProvider<A> serviceProvider,
ApiAdapter<A> apiAdapter)
Creates a new
OAuth2Connection from the data provided. |
OAuth2Connection(String providerId,
String providerUserId,
String accessToken,
String refreshToken,
Long expireTime,
OAuth2ServiceProvider<A> serviceProvider,
ApiAdapter<A> apiAdapter)
Creates a new
OAuth2Connection from a access grant response. |
| Modifier and Type | Method and Description |
|---|---|
ConnectionData |
createData()
Creates a data transfer object that can be used to persist the state of this connection.
|
boolean |
equals(Object obj) |
A |
getApi()
A Java binding to the service provider's native API.
|
boolean |
hasExpired()
Returns true if this connection has expired.
|
int |
hashCode() |
void |
refresh()
Refresh this connection.
|
fetchUserProfile, getDisplayName, getImageUrl, getKey, getMonitor, getProfileUrl, initKey, sync, test, updateStatuspublic OAuth2Connection(String providerId, String providerUserId, String accessToken, String refreshToken, Long expireTime, OAuth2ServiceProvider<A> serviceProvider, ApiAdapter<A> apiAdapter)
OAuth2Connection from a access grant response.
Designed to be called to establish a new OAuth2Connection after receiving an access grant successfully.
The providerUserId may be null in this case: if so, this constructor will try to resolve it using the service API obtained from the OAuth2ServiceProvider.providerId - the provider id e.g. "facebook".providerUserId - the provider user id (may be null if not returned as part of the access grant)accessToken - the granted access tokenrefreshToken - the granted refresh tokenexpireTime - the access token expiration timeserviceProvider - the OAuth2-based ServiceProviderapiAdapter - the ApiAdapter for the ServiceProviderpublic OAuth2Connection(ConnectionData data, OAuth2ServiceProvider<A> serviceProvider, ApiAdapter<A> apiAdapter)
OAuth2Connection from the data provided.
Designed to be called when re-constituting an existing Connection from ConnectionData.data - the data holding the state of this connectionserviceProvider - the OAuth2-based ServiceProviderapiAdapter - the ApiAdapter for the ServiceProviderpublic boolean hasExpired()
ConnectionConnection.test() return false, and any service API invocations fail.
If expired, you may call Connection.refresh() to renew the connection.
Not supported by all Connection implementations; always returns false if not supported.hasExpired in interface Connection<A>hasExpired in class AbstractConnection<A>public void refresh()
ConnectionConnection.hasExpired() returns false.
Not supported by all connection implementations; if not supported, this method is a no-op.refresh in interface Connection<A>refresh in class AbstractConnection<A>public A getApi()
ConnectiongetApi in interface Connection<A>getApi in class AbstractConnection<A>public ConnectionData createData()
ConnectioncreateData in interface Connection<A>createData in class AbstractConnection<A>public int hashCode()
hashCode in class AbstractConnection<A>public boolean equals(Object obj)
equals in class AbstractConnection<A>