final GsonFactory JSON_FACTORY = new GsonFactory(); AuthorizationCodeFlow flow = new AuthorizationCodeFlow.Builder( BearerToken.authorizationHeaderAccessMethod(), HTTP_TRANSPORT, JSON_FACTORY, new GenericUrl(TOKEN_SERVER_URL), new ClientParametersAuthentication(clientId, clientSecret), clientId, AUTHORIZATION_SERVER_URL) .setScopes(scopeList) .setDataStoreFactory(DATA_STORE_FACTORY) .build(); TokenResponse tokenResponse = new RefreshTokenRequest( new NetHttpTransport(), new GsonFactory(), new GenericUrl(TOKEN_SERVER_URL), store.getKey2()) .setClientAuthentication(new BasicAuthentication(this.clientId, this.clientSecret)) .execute();