Search in sources :

Example 1 with ClientParametersAuthentication

use of com.google.api.client.auth.oauth2.ClientParametersAuthentication in project che by eclipse.

the class OAuthAuthenticator method configure.

/**
     * This method should be invoked by child class for initialization default instance of {@link AuthorizationCodeFlow}
     * that will be used for authorization
     */
protected void configure(String clientId, String clientSecret, String[] redirectUris, String authUri, String tokenUri, MemoryDataStoreFactory dataStoreFactory, List<String> scopes) throws IOException {
    final AuthorizationCodeFlow authorizationFlow = new AuthorizationCodeFlow.Builder(BearerToken.authorizationHeaderAccessMethod(), new NetHttpTransport(), new JacksonFactory(), new GenericUrl(tokenUri), new ClientParametersAuthentication(clientId, clientSecret), clientId, authUri).setDataStoreFactory(dataStoreFactory).setScopes(scopes).build();
    LOG.debug("clientId={}, clientSecret={}, redirectUris={} , authUri={}, tokenUri={}, dataStoreFactory={}", clientId, clientSecret, redirectUris, authUri, tokenUri, dataStoreFactory);
    configure(authorizationFlow, Arrays.asList(redirectUris));
}
Also used : ClientParametersAuthentication(com.google.api.client.auth.oauth2.ClientParametersAuthentication) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) GenericUrl(com.google.api.client.http.GenericUrl) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) AuthorizationCodeFlow(com.google.api.client.auth.oauth2.AuthorizationCodeFlow)

Example 2 with ClientParametersAuthentication

use of com.google.api.client.auth.oauth2.ClientParametersAuthentication 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)2 AuthorizationCodeFlow (com.google.api.client.auth.oauth2.AuthorizationCodeFlow)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 GenericUrl (com.google.api.client.http.GenericUrl)1 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)1 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)1