public class OAuthUtils extends Object
Constructor and Description |
---|
OAuthUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
buildAccessTokenURL(CredentialsProvider credentialsProvider)
Helper method for building the access token URL.
|
static okhttp3.Request |
getAccessTokenRequest(CredentialsProvider credentialsProvider,
String authenticationCode,
String callbackURL)
Crafts a POST request to obtain an access token.
|
static okhttp3.Request |
getAccessTokenRequestFromRefreshToken(CredentialsProvider credentialsProvider,
String refreshToken)
Crafts a POST request to obtain an access token.
|
static Map<String,String> |
getOAuthTokens(okhttp3.OkHttpClient client,
okhttp3.Request request)
This function is called in after the user has obtained an OAuth Authorization Code.
|
static okhttp3.RequestBody |
getPostRequest(CredentialsProvider credentialsProvider,
String authorizationCode,
String callbackURL)
Crafts a POST request to obtain an access token.
|
static okhttp3.RequestBody |
getPostRequestForTokenRefresh(CredentialsProvider credentialsProvider,
String refreshToken)
Crafts a POST request for refreshing an access token when a refresh token is present.
|
public static okhttp3.RequestBody getPostRequest(CredentialsProvider credentialsProvider, String authorizationCode, String callbackURL)
credentialsProvider
- A credential provider containing the clientID, clientSecret and authorizationCodeauthorizationCode
- The authorization code from the OAuth2.0 enabled APIcallbackURL
- The callback URL. For our purposes this is obtained from the incoming Drill request as it all goes to the same place.public static okhttp3.RequestBody getPostRequestForTokenRefresh(CredentialsProvider credentialsProvider, String refreshToken)
credentialsProvider
- A credential provider containing the clientID, clientSecret and refreshTokenrefreshToken
- The refresh tokenpublic static String buildAccessTokenURL(CredentialsProvider credentialsProvider)
credentialsProvider
- The credentialsProvider containing all the OAuth pieces.public static okhttp3.Request getAccessTokenRequest(CredentialsProvider credentialsProvider, String authenticationCode, String callbackURL)
credentialsProvider
- The credentialsProvider containing the client_id, client_secret, and auth_code.authenticationCode
- The authentication code from the API.public static okhttp3.Request getAccessTokenRequestFromRefreshToken(CredentialsProvider credentialsProvider, String refreshToken)
credentialsProvider
- The credential provider containing the client_id, client_secret, and refresh token.refreshToken
- The OAuth2.0 refresh tokenpublic static Map<String,String> getOAuthTokens(okhttp3.OkHttpClient client, okhttp3.Request request)
client
- The OkHTTP3 client.request
- The finalized Request to obtain the tokens. This request should be a POST request
containing a client_id, client_secret, authorization code, and grant type.Copyright © 1970 The Apache Software Foundation. All rights reserved.