Example usage for com.google.api.client.googleapis.auth.oauth2 GoogleTokenResponse setTokenType

List of usage examples for com.google.api.client.googleapis.auth.oauth2 GoogleTokenResponse setTokenType

Introduction

In this page you can find the example usage for com.google.api.client.googleapis.auth.oauth2 GoogleTokenResponse setTokenType.

Prototype

@Override
    public GoogleTokenResponse setTokenType(String tokenType) 

Source Link

Usage

From source file:org.gatein.security.oauth.google.GoogleProcessorImpl.java

License:Open Source License

@Override
public GoogleAccessTokenContext getAccessTokenFromUserProfile(UserProfile userProfile, OAuthCodec codec) {
    String encodedAccessToken = OAuthPersistenceUtils.getLongAttribute(userProfile,
            OAuthConstants.PROFILE_GOOGLE_ACCESS_TOKEN, false);
    String decodedAccessToken = codec.decodeString(encodedAccessToken);

    // We don't have token in userProfile
    if (decodedAccessToken == null) {
        return null;
    }/*  w  ww .  ja va 2 s .co  m*/

    String encodedRefreshToken = OAuthPersistenceUtils.getLongAttribute(userProfile,
            OAuthConstants.PROFILE_GOOGLE_REFRESH_TOKEN, false);
    String decodedRefreshToken = codec.decodeString(encodedRefreshToken);
    String decodedScope = codec.decodeString(userProfile.getAttribute(OAuthConstants.PROFILE_GOOGLE_SCOPE));
    GoogleTokenResponse grc = new GoogleTokenResponse();
    grc.setAccessToken(decodedAccessToken);
    grc.setRefreshToken(decodedRefreshToken);
    grc.setTokenType("Bearer");
    grc.setExpiresInSeconds(1000L);
    grc.setIdToken("someTokenId");
    return new GoogleAccessTokenContext(grc, decodedScope);
}