src/main/java/zoot/tube/googleapi/GoogleAuthJava.java
/**
     * Creates a {@link Credential} using a one-time UserCode.
     * <p>
     * Note: Must be using a WebServer to use this method.
     *
     * @param code        the user's code.
     * @param redirectUri an authorized redirectUri known by the Google OAuth Client.
     * @return a Credential for the user the code belongs to.
     */
Creates a  Credential using a one-time UserCode.

Note: Must be using a WebServer to use this method.

@param code        the user's code.
@param redirectUri an authorized redirectUri known by the Google OAuth Client.
@return a Credential for the user the code belongs to.
Creates a Credential using a one - time UserCode . Note : Must be using a WebServer to use this method . @param code the user ' s code . @param redirectUri an authorized redirectUri known by the Google OAuth Client . @return a Credential for the user the code belongs to .
public Credential authorizeUsingUserCode(String code, String redirectUri) {
        Credential credential = this.createEmptyCredential();
        GoogleTokenResponse tokenResponse;
        try {
            tokenResponse = new GoogleAuthorizationCodeTokenRequest(
                    GoogleUtil.getTrustedTransport(),
                    this.jsonFactory,
                    "https://oauth2.googleapis.com/token",
                    this.clientSecrets.getDetails().getClientId(),
                    this.clientSecrets.getDetails().getClientSecret(),
                    code,
                    redirectUri
            ).execute();
        } catch (IOException e) {
            e.printStackTrace();
            return credential;
        }
        credential.setAccessToken(tokenResponse.getAccessToken());
        credential.setRefreshToken(tokenResponse.getRefreshToken());
        return credential;
    }
public Credential authorizeUsingUserCode ( String code , String redirectUri ) { Credential credential = this . createEmptyCredential ( ) ; GoogleTokenResponse tokenResponse ; try { tokenResponse = new GoogleAuthorizationCodeTokenRequest ( GoogleUtil . getTrustedTransport ( ) , this . jsonFactory , "https://oauth2.googleapis.com/token" , this . clientSecrets . getDetails ( ) . getClientId ( ) , this . clientSecrets . getDetails ( ) . getClientSecret ( ) , code , redirectUri ) . execute ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; return credential ; } credential . setAccessToken ( tokenResponse . getAccessToken ( ) ) ; credential . setRefreshToken ( tokenResponse . getRefreshToken ( ) ) ; return credential ; }
Creates a {@link Credential} using a one-time UserCode.
Creates a { @link Credential } using a one - time UserCode .