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
-
Constructor Summary
ConstructorsConstructorDescriptionOAuth20Service(DefaultApi20 api, String apiKey, String apiSecret, String callback, String defaultScope, String responseType, OutputStream debugStream, String userAgent, HttpClientConfig httpClientConfig, HttpClient httpClient) -
Method Summary
Modifier and TypeMethodDescriptionprotected OAuthRequestprotected OAuthRequestcreateAccessTokenDeviceAuthorizationGrantRequest(DeviceAuthorization deviceAuthorization) protected OAuthRequestcreateAccessTokenPasswordGrantRequest(String username, String password, String scope) protected OAuthRequestprotected OAuthRequestprotected OAuthRequestcreateRefreshTokenRequest(String refreshToken, String scope) protected OAuthRequestcreateRevokeTokenRequest(String tokenToRevoke, TokenTypeHint tokenTypeHint) extractAuthorization(String redirectLocation) getAccessToken(AccessTokenRequestParams params, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) Start the request to retrieve the access token.getAccessToken(String code) getAccessToken(String code, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) getAccessTokenAsync(String code) Start the request to retrieve the access token using client-credentials grant.getAccessTokenClientCredentialsGrant(String scope, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) getAccessTokenDeviceAuthorizationGrant(DeviceAuthorization deviceAuthorization) Attempts to get a token from a server.getAccessTokenDeviceAuthorizationGrant(DeviceAuthorization deviceAuthorization, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) getAccessTokenDeviceAuthorizationGrantAsync(DeviceAuthorization deviceAuthorization) getAccessTokenPasswordGrant(String username, String password) getAccessTokenPasswordGrant(String username, String password, String scope) getAccessTokenPasswordGrantAsync(String username, String password) getAccessTokenPasswordGrantAsync(String username, String password, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) Request Access Token Password Grant async versiongetAccessTokenPasswordGrantAsync(String username, String password, String scope) getAccessTokenPasswordGrantAsync(String username, String password, String scope, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) getApi()Returns the URL where you should redirect your users to authenticate your application.getAuthorizationUrl(PKCE pkce) getAuthorizationUrl(String state) getAuthorizationUrl(Map<String, String> additionalParams) Returns the URL where you should redirect your users to authenticate your application.Requests a set of verification codes from the authorization server with the default scopeRequests a set of verification codes from the authorization servergetDeviceAuthorizationCodes(String scope, OAuthAsyncRequestCallback<DeviceAuthorization> callback) Returns the OAuth version of the service.protected voidlogRequestWithParams(String requestDescription, OAuthRequest request) pollAccessTokenDeviceAuthorizationGrant(DeviceAuthorization deviceAuthorization) Periodically tries to get a token from a server (waiting for the user to give consent).refreshAccessToken(String refreshToken) refreshAccessToken(String refreshToken, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) refreshAccessToken(String refreshToken, String scope) refreshAccessToken(String refreshToken, String scope, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) refreshAccessTokenAsync(String refreshToken) refreshAccessTokenAsync(String refreshToken, String scope) voidrevokeToken(String tokenToRevoke) revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback) revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback, TokenTypeHint tokenTypeHint) voidrevokeToken(String tokenToRevoke, TokenTypeHint tokenTypeHint) revokeTokenAsync(String tokenToRevoke) revokeTokenAsync(String tokenToRevoke, TokenTypeHint tokenTypeHint) protected Future<OAuth2AccessToken>sendAccessTokenRequestAsync(OAuthRequest request) protected Future<OAuth2AccessToken>sendAccessTokenRequestAsync(OAuthRequest request, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) protected OAuth2AccessTokensendAccessTokenRequestSync(OAuthRequest request) voidsignRequest(OAuth2AccessToken accessToken, OAuthRequest request) voidsignRequest(String accessToken, OAuthRequest request) Methods inherited from class com.github.scribejava.core.oauth.OAuthService
close, execute, execute, execute, executeAsync, getApiKey, getApiSecret, getCallback, isDebug, log, log
-
Constructor Details
-
OAuth20Service
public OAuth20Service(DefaultApi20 api, String apiKey, String apiSecret, String callback, String defaultScope, String responseType, OutputStream debugStream, String userAgent, HttpClientConfig httpClientConfig, HttpClient httpClient)
-
-
Method Details
-
getVersion
Returns the OAuth version of the service.- Specified by:
getVersionin classOAuthService- Returns:
- OAuth version as string
-
signRequest
-
signRequest
-
getAuthorizationUrl
Returns the URL where you should redirect your users to authenticate your application.- Returns:
- the URL where you should redirect your users
-
getAuthorizationUrl
-
getAuthorizationUrl
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
-
createAuthorizationUrlBuilder
-
getApi
-
extractAuthorization
-
getResponseType
-
getDefaultScope
-
logRequestWithParams
-
sendAccessTokenRequestSync
protected OAuth2AccessToken sendAccessTokenRequestSync(OAuthRequest request) throws IOException, InterruptedException, ExecutionException -
sendAccessTokenRequestAsync
-
sendAccessTokenRequestAsync
protected Future<OAuth2AccessToken> sendAccessTokenRequestAsync(OAuthRequest request, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) -
createAccessTokenRequest
-
getAccessTokenAsync
-
getAccessTokenAsync
-
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) -
createRefreshTokenRequest
-
refreshAccessTokenAsync
-
refreshAccessTokenAsync
-
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) -
createAccessTokenPasswordGrantRequest
protected OAuthRequest createAccessTokenPasswordGrantRequest(String username, String password, 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
-
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) -
createAccessTokenClientCredentialsGrantRequest
-
getAccessTokenClientCredentialsGrantAsync
-
getAccessTokenClientCredentialsGrantAsync
-
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) -
createRevokeTokenRequest
-
revokeTokenAsync
-
revokeTokenAsync
-
revokeToken
public void revokeToken(String tokenToRevoke) throws IOException, InterruptedException, ExecutionException -
revokeToken
public void revokeToken(String tokenToRevoke, TokenTypeHint tokenTypeHint) throws IOException, InterruptedException, ExecutionException -
revokeToken
-
revokeToken
public Future<Void> revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback, TokenTypeHint tokenTypeHint) -
createDeviceAuthorizationCodesRequest
-
getDeviceAuthorizationCodes
public DeviceAuthorization getDeviceAuthorizationCodes() throws InterruptedException, ExecutionException, IOExceptionRequests a set of verification codes from the authorization server with the default scope- Returns:
- DeviceAuthorization
- Throws:
InterruptedException- InterruptedExceptionExecutionException- ExecutionExceptionIOException- IOException- See Also:
-
getDeviceAuthorizationCodes
public DeviceAuthorization getDeviceAuthorizationCodes(String scope) throws InterruptedException, ExecutionException, IOException Requests a set of verification codes from the authorization server- Parameters:
scope- scope- Returns:
- DeviceAuthorization
- Throws:
InterruptedException- InterruptedExceptionExecutionException- ExecutionExceptionIOException- IOException- See Also:
-
getDeviceAuthorizationCodes
public Future<DeviceAuthorization> getDeviceAuthorizationCodes(OAuthAsyncRequestCallback<DeviceAuthorization> callback) -
getDeviceAuthorizationCodes
public Future<DeviceAuthorization> getDeviceAuthorizationCodes(String scope, OAuthAsyncRequestCallback<DeviceAuthorization> callback) -
getDeviceAuthorizationCodesAsync
-
getDeviceAuthorizationCodesAsync
-
createAccessTokenDeviceAuthorizationGrantRequest
protected OAuthRequest createAccessTokenDeviceAuthorizationGrantRequest(DeviceAuthorization deviceAuthorization) -
getAccessTokenDeviceAuthorizationGrant
public OAuth2AccessToken getAccessTokenDeviceAuthorizationGrant(DeviceAuthorization deviceAuthorization) throws InterruptedException, ExecutionException, IOException Attempts to get a token from a server. FunctionpollAccessTokenDeviceAuthorizationGrant(com.github.scribejava.core.model.DeviceAuthorization)is usually used instead of this.- Parameters:
deviceAuthorization- deviceAuthorization- Returns:
- token
- Throws:
InterruptedException- InterruptedExceptionExecutionException- ExecutionExceptionIOException- IOExceptionOAuth2AccessTokenErrorResponse- IfOAuth2AccessTokenErrorResponse.getError()isOAuth2Error.AUTHORIZATION_PENDINGorOAuth2Error.SLOW_DOWN, another attempt should be made after a while.- See Also:
-
getAccessTokenDeviceAuthorizationGrant
public Future<OAuth2AccessToken> getAccessTokenDeviceAuthorizationGrant(DeviceAuthorization deviceAuthorization, OAuthAsyncRequestCallback<OAuth2AccessToken> callback) -
getAccessTokenDeviceAuthorizationGrantAsync
public Future<OAuth2AccessToken> getAccessTokenDeviceAuthorizationGrantAsync(DeviceAuthorization deviceAuthorization) -
pollAccessTokenDeviceAuthorizationGrant
public OAuth2AccessToken pollAccessTokenDeviceAuthorizationGrant(DeviceAuthorization deviceAuthorization) throws InterruptedException, ExecutionException, IOException Periodically tries to get a token from a server (waiting for the user to give consent). Sync only version. No Async variants yet, one should implement async scenarios themselves.- Parameters:
deviceAuthorization- deviceAuthorization- Returns:
- token
- Throws:
InterruptedException- InterruptedExceptionExecutionException- ExecutionExceptionIOException- IOExceptionOAuth2AccessTokenErrorResponse- Indicates OAuth error.- See Also:
-