Search in sources :

Example 1 with DataStoreCredentialRefreshListener

use of com.google.api.client.auth.oauth2.DataStoreCredentialRefreshListener in project openhab1-addons by openhab.

the class GCalGoogleOAuth method newCredential.

private static Credential newCredential(String userId, DataStore<StoredCredential> credentialDataStore) {
    Credential.Builder builder = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod()).setTransport(HTTP_TRANSPORT).setJsonFactory(JSON_FACTORY).setTokenServerEncodedUrl("https://accounts.google.com/o/oauth2/token").setClientAuthentication(new ClientParametersAuthentication(client_id, client_secret)).setRequestInitializer(null).setClock(Clock.SYSTEM);
    builder.addRefreshListener(new DataStoreCredentialRefreshListener(userId, credentialDataStore));
    return builder.build();
}
Also used : ClientParametersAuthentication(com.google.api.client.auth.oauth2.ClientParametersAuthentication) Credential(com.google.api.client.auth.oauth2.Credential) StoredCredential(com.google.api.client.auth.oauth2.StoredCredential) DataStoreCredentialRefreshListener(com.google.api.client.auth.oauth2.DataStoreCredentialRefreshListener)

Aggregations

ClientParametersAuthentication (com.google.api.client.auth.oauth2.ClientParametersAuthentication)1 Credential (com.google.api.client.auth.oauth2.Credential)1 DataStoreCredentialRefreshListener (com.google.api.client.auth.oauth2.DataStoreCredentialRefreshListener)1 StoredCredential (com.google.api.client.auth.oauth2.StoredCredential)1