Package com.google.api.client.googleapis.auth.oauth2

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


    when(configurationHelper.fromFile("path")).thenReturn(config);

    GoogleClientSecretsForApiBuilder builder = new GoogleClientSecretsForApiBuilder(
        configurationHelper, GoogleClientSecretsBuilder.Api.DFP);

    GoogleClientSecrets googleClientSecrets = builder.fromFile("path").build();

    assertEquals(googleClientSecrets.getInstalled().getClientId(), "clientId");
    assertEquals(googleClientSecrets.getInstalled().getClientSecret(), "clientSecret");
  }
View Full Code Here


      JsonFactory jsonFactory = new JacksonFactory();

      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)
View Full Code Here

     *            list of scopes needed to run youtube upload.
     */
    private static Credential authorize(List<String> scopes) throws Exception {

        // Load client secrets.
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
                JSON_FACTORY,
                YoutubeVideoServiceImpl.class.getResourceAsStream("/client_secrets.json"));

        // Checks that the defaults have been replaced (Default =
        // "Enter X here").
        if (clientSecrets.getDetails().getClientId().startsWith("Enter")
                || clientSecrets.getDetails().getClientSecret()
                        .startsWith("Enter ")) {
            logger.error("Enter Client ID and Secret from https://code.google.com/apis/console/?api=youtube"
                    + "into youtube-cmdline-uploadvideo-sample/src/main/resources/client_secrets.json");
                   
            System.exit(1);
View Full Code Here

     * Overriding is only supported for the purpose of calling the super implementation and changing
     * the return type, but nothing else.
     * </p>
     */
    public Builder setClientSecrets(GoogleClientSecrets clientSecrets) {
      Details details = clientSecrets.getDetails();
      setClientAuthentication(
          new ClientParametersAuthentication(details.getClientId(), details.getClientSecret()));
      return this;
    }
View Full Code Here

      + "\",\"client_secret\": \"" + CLIENT_SECRET + "\"}}";

  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());
  }
View Full Code Here

     * Overriding is only supported for the purpose of calling the super implementation and changing
     * the return type, but nothing else.
     * </p>
     */
    public Builder setClientSecrets(GoogleClientSecrets clientSecrets) {
      Details details = clientSecrets.getDetails();
      setClientAuthentication(
          new ClientParametersAuthentication(details.getClientId(), details.getClientSecret()));
      return this;
    }
View Full Code Here

     * Overriding is only supported for the purpose of calling the super implementation and changing
     * the return type, but nothing else.
     * </p>
     */
    public Builder setClientSecrets(GoogleClientSecrets clientSecrets) {
      Details details = clientSecrets.getDetails();
      setClientAuthentication(
          new ClientParametersAuthentication(details.getClientId(), details.getClientSecret()));
      return this;
    }
View Full Code Here

    } else {
      throw new OpsException("Expected private key, found: " + parsed.getClass().getSimpleName());
    }

    // Build service account credential.
    GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
        .setJsonFactory(JSON_FACTORY).setServiceAccountId(cloud.serviceAccountId)
        .setServiceAccountScopes(ComputeScopes.COMPUTE).setServiceAccountPrivateKey(privateKey).build();

    Compute compute = new Compute(HTTP_TRANSPORT, JSON_FACTORY, credential);
View Full Code Here

            @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

        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

TOP

Related Classes of com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets

Copyright © 2018 www.massapicom. 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.