S
- the service API type.public class OAuth2ConnectionFactory<S> extends ConnectionFactory<S>
Connection
s.
May be subclassed to further simplify construction e.g. FacebookConnectionFactory.Constructor and Description |
---|
OAuth2ConnectionFactory(String providerId,
OAuth2ServiceProvider<S> serviceProvider,
ApiAdapter<S> apiAdapter)
Create a
OAuth2ConnectionFactory . |
Modifier and Type | Method and Description |
---|---|
Connection<S> |
createConnection(AccessGrant accessGrant)
|
Connection<S> |
createConnection(ConnectionData data)
Create a OAuth2-based
Connection from the connection data. |
protected String |
extractProviderUserId(AccessGrant accessGrant)
Hook for extracting the providerUserId from the returned
AccessGrant , if it is available. |
String |
generateState()
Generates a value for the state parameter.
|
OAuth2Operations |
getOAuthOperations()
Get the ServiceProvider's
OAuth2Operations that allows the client application to conduct the OAuth2 flow with the provider. |
String |
getScope() |
void |
setScope(String scope)
Sets the default value to send in the scope parameter during authorization.
|
boolean |
supportsStateParameter()
Indicates that this provider supports the state parameter in callbacks to prevent against CSRF.
|
getApiAdapter, getProviderId, getServiceProvider
public OAuth2ConnectionFactory(String providerId, OAuth2ServiceProvider<S> serviceProvider, ApiAdapter<S> apiAdapter)
OAuth2ConnectionFactory
.providerId
- the provider id e.g. "facebook"serviceProvider
- the ServiceProvider model for conducting the authorization flow and obtaining a native service API instance.apiAdapter
- the ApiAdapter for mapping the provider-specific service API model to the uniform Connection
interface.public void setScope(String scope)
scope
- The default value to send as scope during authorization.public String getScope()
public String generateState()
public boolean supportsStateParameter()
public OAuth2Operations getOAuthOperations()
OAuth2Operations
that allows the client application to conduct the OAuth2 flow with the provider.public Connection<S> createConnection(AccessGrant accessGrant)
accessGrant
- the access grantOAuth2Operations.exchangeForAccess(String, String, org.springframework.util.MultiValueMap)
public Connection<S> createConnection(ConnectionData data)
Connection
from the connection data.createConnection
in class ConnectionFactory<S>
data
- connection data from which to create the connectionprotected String extractProviderUserId(AccessGrant accessGrant)
AccessGrant
, if it is available.
Default implementation returns null, indicating it is not exposed and another remote API call will be required to obtain it.
Subclasses may override.accessGrant
- an AccessGrant from which to extract the provider ID