Examples of GoogleCredential


Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

        authorizationFlow.newTokenRequest(authorizationCode);
    tokenRequest.setRedirectUri(CALLBACK_URL);
    GoogleTokenResponse tokenResponse = tokenRequest.execute();

    // Create the OAuth2 credential.
    GoogleCredential credential = new GoogleCredential.Builder()
        .setTransport(new NetHttpTransport())
        .setJsonFactory(new JacksonFactory())
        .setClientSecrets(clientSecrets)
        .build();

    // Set authorized credentials.
    credential.setFromTokenResponse(tokenResponse);

    return credential;
  }
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

        authorizationFlow.newTokenRequest(authorizationCode);
    tokenRequest.setRedirectUri(CALLBACK_URL);
    GoogleTokenResponse tokenResponse = tokenRequest.execute();

    // Create the OAuth2 credential.
    GoogleCredential credential = new GoogleCredential.Builder()
        .setTransport(new NetHttpTransport())
        .setJsonFactory(new JacksonFactory())
        .setClientSecrets(clientSecrets)
        .build();

    // Set authorized credentials.
    credential.setFromTokenResponse(tokenResponse);

    return credential;
  }
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

            @Override
            protected Tokeninfo invokeRequest(GoogleAccessTokenContext accessTokenContext) throws IOException {
                GoogleTokenResponse tokenData = accessTokenContext.getTokenData();
                Oauth2 oauth2 = getOAuth2InstanceImpl(tokenData);
                GoogleCredential credential = getGoogleCredential(tokenData);
                return oauth2.tokeninfo().setAccessToken(credential.getAccessToken()).execute();
            }

            @Override
            protected OAuthException createException(IOException cause) {
                if (cause instanceof HttpResponseException) {
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

        GoogleTokenResponse tokenData = accessTokenContext.getTokenData();
        return getOAuth2InstanceImpl(tokenData);
    }

    protected Oauth2 getOAuth2InstanceImpl(GoogleTokenResponse tokenData) {
        GoogleCredential credential = getGoogleCredential(tokenData);
        return new Oauth2.Builder(TRANSPORT, JSON_FACTORY, credential).setApplicationName(applicationName).build();
    }
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

    @Override
    public Plus getPlusService(GoogleAccessTokenContext accessTokenContext) {
        GoogleTokenResponse tokenData = accessTokenContext.getTokenData();
        // Build credential from stored token data.
        GoogleCredential credential = getGoogleCredential(tokenData);

        // Create a new authorized API client.
        Plus service = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential)
                .setApplicationName(applicationName)
                .build();
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

      URL url = Resources.getResource(GDrive.class, CLIENTSECRETS_LOCATION);
      CharSource charSource = Resources.asCharSource(url, Charsets.UTF_8);
      Reader reader = charSource.openStream();
      GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(jsonFactory, reader);

      GoogleCredential credential = new GoogleCredential.Builder()
          .setTransport(httpTransport)
          .setJsonFactory(jsonFactory)
          .setClientSecrets(clientSecrets)
          .build();

      credential.setAccessToken(tokens.accessToken);
      credential.setRefreshToken(tokens.refreshToken);

      Drive drive = new Drive.Builder(httpTransport, jsonFactory, credential)
          .setApplicationName("GDrive")
          .build();
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

   */
  @Test
  public void testGoldenSoap_oauth2() throws Exception {
    testHttpServer.setMockResponseBody(SoapResponseXmlProvider.getTestSoapResponse(API_VERSION));

    GoogleCredential credential = new GoogleCredential.Builder().setTransport(
        new NetHttpTransport()).setJsonFactory(new JacksonFactory()).build();
    credential.setAccessToken("TEST_ACCESS_TOKEN");

    DfpSession session = new DfpSession.Builder().withApplicationName("TEST_APP")
        .withOAuth2Credential(credential)
        .withEndpoint(testHttpServer.getServerUrl())
        .withNetworkCode("TEST_NETWORK_CODE")
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

      URL url = Resources.getResource(GDrive.class, CLIENTSECRETS_LOCATION);
      CharSource charSource = Resources.asCharSource(url, Charsets.UTF_8);
      Reader reader = charSource.openStream();
      GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(jsonFactory, reader);

      GoogleCredential credential = new GoogleCredential.Builder()
          .setTransport(httpTransport)
          .setJsonFactory(jsonFactory)
          .setClientSecrets(clientSecrets)
          .build();

      credential.setAccessToken(tokens.accessToken);
      credential.setRefreshToken(tokens.refreshToken);

      Drive drive = new Drive.Builder(httpTransport, jsonFactory, credential)
          .setApplicationName("GDrive")
          .build();
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

  log.info("SERVLET init");
  getParams(config);

  // set .level = CONFIG in logging.properties to see the OAuth exchange in the logs
  log.info("GoogleCredential requesting credential");
  GoogleCredential credential = null;

  // for debugging if the file isn't found
  File keyfile = new File(keystorefilename);
  String abspath = keyfile.getAbsolutePath();
  log.info("keyfile absolute path: " + abspath);
View Full Code Here

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleCredential

  }

  private Drive getDriveService() throws IOException, GeneralSecurityException {

    if (driveService == null) {
      GoogleCredential credential = new GoogleCredential.Builder()
        .setTransport(HTTP_TRANSPORT) //
        .setJsonFactory(JSON_FACTORY) //
        .setServiceAccountId(this.serviceEmail) //
        .setServiceAccountScopes(DriveScopes.DRIVE) //
        .setServiceAccountPrivateKeyFromP12File(new java.io.File(this.privateKeyFilePath)) //
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.