public class GenericOAuth2ServiceProvider extends AbstractOAuth2ServiceProvider<RestOperations>
OAuth2ServiceProvider
that carries no intrinsic knowledge of the API it will be creating connections against.
Instead, it must be configured with API provider-specific details.
This enables developers to use Spring Social to create connections against any API for which there isn't a ready-to-use connection support and API binding
without creating one-off connection factory and service provider implementations.
The API binding provided by this service provider is simply a RestOperations
, but the underlying RestTemplate
is configured to automatically
add Authorization
headers to all requests.Constructor and Description |
---|
GenericOAuth2ServiceProvider(String appId,
String appSecret,
String authorizeUrl,
String authenticateUrl,
String accessTokenUrl,
boolean useParametersForClientCredentials,
TokenStrategy tokenStrategy)
Creates an instance of GenericOAuth1ServiceProvider for a provider that offers a separate authentication URL.
|
Modifier and Type | Method and Description |
---|---|
RestOperations |
getApi(String accessToken)
Returns an API interface allowing the client application to access protected resources on behalf of a user.
|
getOAuthOperations
public GenericOAuth2ServiceProvider(String appId, String appSecret, String authorizeUrl, String authenticateUrl, String accessTokenUrl, boolean useParametersForClientCredentials, TokenStrategy tokenStrategy)
appId
- The application's ID/key for the API.appSecret
- The application's secret for the API.authorizeUrl
- The API's OAuth 2 authorization URL.authenticateUrl
- The API's OAuth 2 authentication URL. If null, then the authorization URL will be used by default.accessTokenUrl
- The API's OAuth 2 access token URL.useParametersForClientCredentials
- If true, client credentials will be sent as parameters. If false, the client with be authenticated via HTTP BasictokenStrategy
- The token strategy indicating how the access token should be carried on API requests.public RestOperations getApi(String accessToken)
OAuth2ServiceProvider
getApi
in interface OAuth2ServiceProvider<RestOperations>
getApi
in class AbstractOAuth2ServiceProvider<RestOperations>
accessToken
- the API access token