Package com.github.scribejava.core.oauth
Class OAuth20Service
- java.lang.Object
-
- com.github.scribejava.core.oauth.OAuthService
-
- com.github.scribejava.core.oauth.OAuth20Service
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class OAuth20Service extends OAuthService
-
-
Constructor Summary
Constructors Constructor Description OAuth20Service(DefaultApi20 api, String apiKey, String apiSecret, String callback, String defaultScope, String responseType, OutputStream debugStream, String userAgent, HttpClientConfig httpClientConfig, HttpClient httpClient)
-
Method Summary
-
Methods inherited from class com.github.scribejava.core.oauth.OAuthService
close, execute, execute, execute, executeAsync, getApiKey, getApiSecret, getCallback, isDebug, log, log
-
-
-
-
Constructor Detail
-
OAuth20Service
public OAuth20Service(DefaultApi20 api, String apiKey, String apiSecret, String callback, String defaultScope, String responseType, OutputStream debugStream, String userAgent, HttpClientConfig httpClientConfig, HttpClient httpClient)
-
-
Method Detail
-
sendAccessTokenRequestSync
protected OAuth2AccessToken sendAccessTokenRequestSync(OAuthRequest request) throws IOException, InterruptedException, ExecutionException
-
sendAccessTokenRequestAsync
protected Future<OAuth2AccessToken> sendAccessTokenRequestAsync(OAuthRequest request)
-
sendAccessTokenRequestAsync
protected Future<OAuth2AccessToken> sendAccessTokenRequestAsync(OAuthRequest request, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
getAccessTokenAsync
public Future<OAuth2AccessToken> getAccessTokenAsync(String code)
-
getAccessTokenAsync
public Future<OAuth2AccessToken> getAccessTokenAsync(AccessTokenRequestParams params)
-
getAccessToken
public OAuth2AccessToken getAccessToken(String code) throws IOException, InterruptedException, ExecutionException
-
getAccessToken
public OAuth2AccessToken getAccessToken(AccessTokenRequestParams params) throws IOException, InterruptedException, ExecutionException
-
getAccessToken
public Future<OAuth2AccessToken> getAccessToken(AccessTokenRequestParams params, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
Start the request to retrieve the access token. The optionally provided callback will be called with the Token when it is available.- Parameters:
params
- paramscallback
- optional callback- Returns:
- Future
-
getAccessToken
public Future<OAuth2AccessToken> getAccessToken(String code, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
createAccessTokenRequest
protected OAuthRequest createAccessTokenRequest(AccessTokenRequestParams params)
-
refreshAccessTokenAsync
public Future<OAuth2AccessToken> refreshAccessTokenAsync(String refreshToken)
-
refreshAccessTokenAsync
public Future<OAuth2AccessToken> refreshAccessTokenAsync(String refreshToken, String scope)
-
refreshAccessToken
public OAuth2AccessToken refreshAccessToken(String refreshToken) throws IOException, InterruptedException, ExecutionException
-
refreshAccessToken
public OAuth2AccessToken refreshAccessToken(String refreshToken, String scope) throws IOException, InterruptedException, ExecutionException
-
refreshAccessToken
public Future<OAuth2AccessToken> refreshAccessToken(String refreshToken, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
refreshAccessToken
public Future<OAuth2AccessToken> refreshAccessToken(String refreshToken, String scope, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
createRefreshTokenRequest
protected OAuthRequest createRefreshTokenRequest(String refreshToken, String scope)
-
getAccessTokenPasswordGrant
public OAuth2AccessToken getAccessTokenPasswordGrant(String username, String password) throws IOException, InterruptedException, ExecutionException
-
getAccessTokenPasswordGrant
public OAuth2AccessToken getAccessTokenPasswordGrant(String username, String password, String scope) throws IOException, InterruptedException, ExecutionException
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password)
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password, String scope)
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
Request Access Token Password Grant async version- Parameters:
username
- User namepassword
- User passwordcallback
- Optional callback- Returns:
- Future
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String username, String password, String scope, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
createAccessTokenPasswordGrantRequest
protected OAuthRequest createAccessTokenPasswordGrantRequest(String username, String password, String scope)
-
getAccessTokenClientCredentialsGrantAsync
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrantAsync()
-
getAccessTokenClientCredentialsGrantAsync
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrantAsync(String scope)
-
getAccessTokenClientCredentialsGrant
public OAuth2AccessToken getAccessTokenClientCredentialsGrant() throws IOException, InterruptedException, ExecutionException
-
getAccessTokenClientCredentialsGrant
public OAuth2AccessToken getAccessTokenClientCredentialsGrant(String scope) throws IOException, InterruptedException, ExecutionException
-
getAccessTokenClientCredentialsGrant
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrant(OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
Start the request to retrieve the access token using client-credentials grant. The optionally provided callback will be called with the Token when it is available.- Parameters:
callback
- optional callback- Returns:
- Future
-
getAccessTokenClientCredentialsGrant
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrant(String scope, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
createAccessTokenClientCredentialsGrantRequest
protected OAuthRequest createAccessTokenClientCredentialsGrantRequest(String scope)
-
getVersion
public String getVersion()
Returns the OAuth version of the service.- Specified by:
getVersion
in classOAuthService
- Returns:
- OAuth version as string
-
signRequest
public void signRequest(String accessToken, OAuthRequest request)
-
signRequest
public void signRequest(OAuth2AccessToken accessToken, OAuthRequest request)
-
getAuthorizationUrl
public String getAuthorizationUrl()
Returns the URL where you should redirect your users to authenticate your application.- Returns:
- the URL where you should redirect your users
-
getAuthorizationUrl
public String getAuthorizationUrl(Map<String,String> additionalParams)
Returns the URL where you should redirect your users to authenticate your application.- Parameters:
additionalParams
- any additional GET params to add to the URL- Returns:
- the URL where you should redirect your users
-
createAuthorizationUrlBuilder
public AuthorizationUrlBuilder createAuthorizationUrlBuilder()
-
getApi
public DefaultApi20 getApi()
-
createRevokeTokenRequest
protected OAuthRequest createRevokeTokenRequest(String tokenToRevoke, TokenTypeHint tokenTypeHint)
-
revokeTokenAsync
public Future<Void> revokeTokenAsync(String tokenToRevoke, TokenTypeHint tokenTypeHint)
-
revokeToken
public void revokeToken(String tokenToRevoke) throws IOException, InterruptedException, ExecutionException
-
revokeToken
public void revokeToken(String tokenToRevoke, TokenTypeHint tokenTypeHint) throws IOException, InterruptedException, ExecutionException
-
revokeToken
public Future<Void> revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback)
-
revokeToken
public Future<Void> revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback, TokenTypeHint tokenTypeHint)
-
extractAuthorization
public OAuth2Authorization extractAuthorization(String redirectLocation)
-
getResponseType
public String getResponseType()
-
getDefaultScope
public String getDefaultScope()
-
-