Search in sources :

Example 1 with GetAccessTokenResult

use of com.google.appengine.api.appidentity.AppIdentityService.GetAccessTokenResult in project google-auth-library-java by google.

the class AppEngineCredentials method refreshAccessToken.

/**
 * Refresh the access token by getting it from the App Identity service
 */
@Override
public AccessToken refreshAccessToken() throws IOException {
    if (createScopedRequired()) {
        throw new IOException("AppEngineCredentials requires createScoped call before use.");
    }
    GetAccessTokenResult accessTokenResponse = appIdentityService.getAccessToken(scopes);
    String accessToken = accessTokenResponse.getAccessToken();
    Date expirationTime = accessTokenResponse.getExpirationTime();
    return new AccessToken(accessToken, expirationTime);
}
Also used : AccessToken(com.google.auth.oauth2.AccessToken) IOException(java.io.IOException) GetAccessTokenResult(com.google.appengine.api.appidentity.AppIdentityService.GetAccessTokenResult) Date(java.util.Date)

Aggregations

GetAccessTokenResult (com.google.appengine.api.appidentity.AppIdentityService.GetAccessTokenResult)1 AccessToken (com.google.auth.oauth2.AccessToken)1 IOException (java.io.IOException)1 Date (java.util.Date)1