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, 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
-
-
-
-
Constructor Detail
-
OAuth20Service
public OAuth20Service(DefaultApi20 api, String apiKey, String apiSecret, String callback, String defaultScope, String responseType, 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
@Deprecated public Future<OAuth2AccessToken> getAccessTokenAsync(String code, String pkceCodeVerifier)
- Parameters:
code
- codepkceCodeVerifier
- pkceCodeVerifier- Returns:
- future
-
getAccessTokenAsync
public Future<OAuth2AccessToken> getAccessTokenAsync(AccessTokenRequestParams params)
-
getAccessToken
public OAuth2AccessToken getAccessToken(String code) throws IOException, InterruptedException, ExecutionException
-
getAccessToken
@Deprecated public OAuth2AccessToken getAccessToken(String code, String pkceCodeVerifier) throws IOException, InterruptedException, ExecutionException
- Parameters:
code
- codepkceCodeVerifier
- pkceCodeVerifier- Returns:
- token
- Throws:
IOException
- IOExceptionInterruptedException
- InterruptedExceptionExecutionException
- 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
@Deprecated public Future<OAuth2AccessToken> getAccessToken(String code, OAuthAsyncRequestCallback<OAuth2AccessToken> callback, String pkceCodeVerifier)
Deprecated.- Parameters:
code
- codecallback
- callbackpkceCodeVerifier
- pkceCodeVerifier- Returns:
- future
-
getAccessToken
public Future<OAuth2AccessToken> getAccessToken(String code, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
createAccessTokenRequest
@Deprecated protected OAuthRequest createAccessTokenRequest(String code)
- Parameters:
code
- code- Returns:
- request
-
createAccessTokenRequest
@Deprecated protected OAuthRequest createAccessTokenRequest(String code, String pkceCodeVerifier)
- Parameters:
code
- codepkceCodeVerifier
- pkceCodeVerifier- Returns:
- request
-
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
@Deprecated protected OAuthRequest createRefreshTokenRequest(String refreshToken)
Deprecated.- Parameters:
refreshToken
- refreshToken- Returns:
- request
-
createRefreshTokenRequest
protected OAuthRequest createRefreshTokenRequest(String refreshToken, String scope)
-
getAccessTokenPasswordGrant
public OAuth2AccessToken getAccessTokenPasswordGrant(String uname, String password) throws IOException, InterruptedException, ExecutionException
-
getAccessTokenPasswordGrant
public OAuth2AccessToken getAccessTokenPasswordGrant(String uname, String password, String scope) throws IOException, InterruptedException, ExecutionException
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password)
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password, String scope)
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
Request Access Token Password Grant async version- Parameters:
uname
- User namepassword
- User passwordcallback
- Optional callback- Returns:
- Future
-
getAccessTokenPasswordGrantAsync
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password, String scope, OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
-
createAccessTokenPasswordGrantRequest
@Deprecated protected OAuthRequest createAccessTokenPasswordGrantRequest(String username, String password)
Deprecated.- Parameters:
username
- usernamepassword
- password- Returns:
- request
-
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
@Deprecated protected OAuthRequest createAccessTokenClientCredentialsGrantRequest()
Deprecated.- Returns:
- request
-
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)
-
getAuthorizationUrlWithPKCE
@Deprecated public AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE()
Deprecated.use new builder patternAuthorizationUrlBuilder
- Returns:
- AuthorizationUrlWithPKCE
-
getAuthorizationUrlWithPKCE
@Deprecated public AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE(String state)
Deprecated.use new builder patternAuthorizationUrlBuilder
- Parameters:
state
- state- Returns:
- AuthorizationUrlWithPKCE
-
getAuthorizationUrlWithPKCE
@Deprecated public AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE(Map<String,String> additionalParams)
Deprecated.use new builder patternAuthorizationUrlBuilder
- Parameters:
additionalParams
- additionalParams- Returns:
- AuthorizationUrlWithPKCE
-
getAuthorizationUrlWithPKCE
@Deprecated public AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE(String state, Map<String,String> additionalParams)
Deprecated.use new builder patternAuthorizationUrlBuilder
- Parameters:
state
- stateadditionalParams
- additionalParams- Returns:
- AuthorizationUrlWithPKCE
-
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
-
getAuthorizationUrl
@Deprecated public String getAuthorizationUrl(String state, Map<String,String> additionalParams)
Deprecated.use new builder patternAuthorizationUrlBuilder
- Parameters:
state
- stateadditionalParams
- additionalParams- Returns:
- url
-
getAuthorizationUrl
@Deprecated public String getAuthorizationUrl(String state, PKCE pkce)
Deprecated.use new builder patternAuthorizationUrlBuilder
- Parameters:
state
- statepkce
- pkce- Returns:
- url
-
getAuthorizationUrl
@Deprecated public String getAuthorizationUrl(Map<String,String> additionalParams, PKCE pkce)
Deprecated.use new builder patternAuthorizationUrlBuilder
- Parameters:
additionalParams
- additionalParamspkce
- pkce- Returns:
- url
-
getAuthorizationUrl
@Deprecated public String getAuthorizationUrl(String state, Map<String,String> additionalParams, PKCE pkce)
Deprecated.use new builder patternAuthorizationUrlBuilder
- Parameters:
state
- stateadditionalParams
- additionalParamspkce
- pkce- Returns:
- url
-
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()
-
-