Search in sources :

Example 1 with Details

use of com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.Details in project muikku by otavanopisto.

the class GoogleCalendarClient method getAccessTokenCredential.

@SuppressWarnings("unused")
private GoogleCredential getAccessTokenCredential() {
    AccessToken googleAccessToken = sessionController.getOAuthAccessToken("google");
    if (googleAccessToken != null) {
        Details details = new Details();
        details.setClientId("-");
        details.setClientSecret("-");
        GoogleClientSecrets secrets = new GoogleClientSecrets();
        secrets.setWeb(details);
        return new GoogleCredential.Builder().setClientSecrets(secrets).setTransport(TRANSPORT).setJsonFactory(JSON_FACTORY).build().setAccessToken(googleAccessToken.getToken());
    }
    return null;
}
Also used : Details(com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.Details) AccessToken(fi.otavanopisto.muikku.session.AccessToken) GoogleClientSecrets(com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets) GoogleCredential(com.google.api.client.googleapis.auth.oauth2.GoogleCredential)

Example 2 with Details

use of com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.Details in project google-api-java-client by google.

the class GoogleClientSecretsTest method testLoad.

public void testLoad() throws Exception {
    GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(new GsonFactory(), new StringReader(CLIENT_SECRETS));
    Details installed = clientSecrets.getInstalled();
    assertNotNull(installed);
    assertEquals(CLIENT_ID, installed.getClientId());
    assertEquals(CLIENT_SECRET, installed.getClientSecret());
}
Also used : GsonFactory(com.google.api.client.json.gson.GsonFactory) Details(com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.Details) StringReader(java.io.StringReader)

Aggregations

Details (com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.Details)2 GoogleClientSecrets (com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets)1 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)1 GsonFactory (com.google.api.client.json.gson.GsonFactory)1 AccessToken (fi.otavanopisto.muikku.session.AccessToken)1 StringReader (java.io.StringReader)1