Search in sources :

Example 1 with RefreshTokenRequest

use of com.google.api.client.auth.oauth2.RefreshTokenRequest in project hub-alert by blackducksoftware.

the class AzureCredential method executeRefreshToken.

@Override
protected TokenResponse executeRefreshToken() throws IOException {
    String refreshToken = getRefreshToken();
    if (refreshToken == null) {
        if (cachedRefreshToken == null) {
            return null;
        }
        refreshToken = cachedRefreshToken;
    }
    RefreshTokenRequest request = new RefreshTokenRequest(getTransport(), getJsonFactory(), new GenericUrl(getTokenServerEncodedUrl()), refreshToken);
    request.setClientAuthentication(getClientAuthentication());
    request.setRequestInitializer(getRequestInitializer());
    request.setResponseClass(AzureTokenResponse.class);
    request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_ASSERTION, refreshToken);
    request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION_TYPE, AzureOAuthConstants.DEFAULT_CLIENT_ASSERTION_TYPE);
    request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION, clientSecret);
    request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_REDIRECT_URI, redirectUri);
    return request.execute();
}
Also used : RefreshTokenRequest(com.google.api.client.auth.oauth2.RefreshTokenRequest) GenericUrl(com.google.api.client.http.GenericUrl)

Aggregations

RefreshTokenRequest (com.google.api.client.auth.oauth2.RefreshTokenRequest)1 GenericUrl (com.google.api.client.http.GenericUrl)1