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

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder


     */
    private static Credential authorizeWithInstalledApplication() throws IOException {
        log.info("Authorizing using installed application");

        // load client secrets
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
                JSON_FACTORY,
                new InputStreamReader(
                        AndroidPublisherHelper.class
                                .getResourceAsStream(RESOURCES_CLIENT_SECRETS_JSON)));
        // Ensure file has been filled out.
View Full Code Here


     */
    public static Credential authorize(List<String> scopes, String credentialDatastore) throws IOException {

        // Load client secrets.
        Reader clientSecretReader = new InputStreamReader(Auth.class.getResourceAsStream("/client_secrets.json"));
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, clientSecretReader);

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

      File credentialDataStore) throws IOException {

    FileCredentialStore credentialStore = new FileCredentialStore(
        credentialDataStore, JSON_FACTORY);

    GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
        JSON_FACTORY,
        Auth.class.getResourceAsStream("/client_secrets.json"));

    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
        HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, scopes)
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.GoogleAuthorizationCodeFlow$Builder

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.