src/main/java/zoot/tube/googleapi/GoogleAuthJava.java
/**
     * Creates a fresh {@link Credential} for a user.
     * <p>
     * If there is an error while retrieving the Credential, an
     * empty Credential will be returned.
     * <p>
     * This call originates the auth request from this, and does
     * not use a webserver. So the client secrets MUST NOT require
     * a redirect Url. (The OAuth uses the "other" type).
     *
     * @param userId userId or {@code null} if not using a persisted credential store.
     * @return a Credential.
     */
Creates a fresh  Credential for a user.

If there is an error while retrieving the Credential, an
empty Credential will be returned.

This call originates the auth request from this, and does
not use a webserver. So the client secrets MUST NOT require
a redirect Url. (The OAuth uses the "other" type).

@param userId userId or  null if not using a persisted credential store.
@return a Credential.
Creates a fresh Credential for a user . If there is an error while retrieving the Credential an empty Credential will be returned . This call originates the auth request from this and does not use a webserver . So the client secrets MUST NOT require a redirect Url . ( The OAuth uses the " other " type ) . @param userId userId or null if not using a persisted credential store . @return a Credential .
public Credential authorizeAndGetNewCredential(String userId) {
        Credential credential = this.createEmptyCredential();
        GoogleAuthorizationCodeFlow flow = this.getAuthorizationCodeFlow();
        try {
            credential = new AuthorizationCodeInstalledApp(
                    flow,
                    new LocalServerReceiver()
            ).authorize(userId);
        } catch (IOException e) {
            System.err.println("GoogleAuthJava: Failed to authenticate user: " + userId);
            e.printStackTrace();
        }
        return credential;
    }
public Credential authorizeAndGetNewCredential ( String userId ) { Credential credential = this . createEmptyCredential ( ) ; GoogleAuthorizationCodeFlow flow = this . getAuthorizationCodeFlow ( ) ; try { credential = new AuthorizationCodeInstalledApp ( flow , new LocalServerReceiver ( ) ) . authorize ( userId ) ; } catch ( IOException e ) { System . err . println ( "GoogleAuthJava: Failed to authenticate user: " + userId ) ; e . printStackTrace ( ) ; } return credential ; }
Creates a fresh {@link Credential} for a user.
Creates a fresh { @link Credential } for a user .
// Create an empty Credential. // Get an authorization code flow. // Attempt to have user authorize this app. // Attempts to open a Google authorization page in the default web browser.