public OAuthFuture<Credential> authorizeExplicitly(final String userId,
            final OAuthCallback<Credential> callback, Handler handler) {
        Preconditions.checkNotNull(userId);

        final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) {

            @Override
            public void doWork() throws Exception {
                try {
                    Credential credential = mFlow.loadCredential(userId);
                    LOGGER.info("authorizeExplicitly");
                    if (credential != null && credential.getAccessToken() != null
                            && (credential.getRefreshToken() != null ||
                                    credential.getExpiresInSeconds() == null ||
                            credential.getExpiresInSeconds() > 60)) {
                        set(credential);
                        return;
                    }

                    String redirectUri = mUIController.getRedirectUri();

                    AuthorizationCodeRequestUrl authorizationUrl = mFlow
                            .newExplicitAuthorizationUrl()
                            .setRedirectUri(redirectUri);
                    mUIController.requestAuthorization(authorizationUrl);

                    String code = mUIController.waitForExplicitCode();
                    TokenResponse response = mFlow.newTokenRequest(code)
                            .setRedirectUri(redirectUri).execute();
                    credential = mFlow.createAndStoreCredential(response, userId);
                    set(credential);
                } finally {
                    mUIController.stop();
                }
            }

        };

        // run the task in a background thread
        submitTaskToExecutor(task);

        return task;
    }
public OAuthFuture < Credential > authorizeExplicitly ( final String userId , final OAuthCallback < Credential > callback , Handler handler ) { Preconditions . checkNotNull ( userId ) ; final Future2Task < Credential > task = new Future2Task < Credential > ( handler , callback ) { @ Override public void doWork ( ) throws Exception { try { Credential credential = mFlow . loadCredential ( userId ) ; LOGGER . info ( "authorizeExplicitly" ) ; if ( credential != null && credential . getAccessToken ( ) != null && ( credential . getRefreshToken ( ) != null || credential . getExpiresInSeconds ( ) == null || credential . getExpiresInSeconds ( ) > 60 ) ) { set ( credential ) ; return ; } String redirectUri = mUIController . getRedirectUri ( ) ; AuthorizationCodeRequestUrl authorizationUrl = mFlow . newExplicitAuthorizationUrl ( ) . setRedirectUri ( redirectUri ) ; mUIController . requestAuthorization ( authorizationUrl ) ; String code = mUIController . waitForExplicitCode ( ) ; TokenResponse response = mFlow . newTokenRequest ( code ) . setRedirectUri ( redirectUri ) . execute ( ) ; credential = mFlow . createAndStoreCredential ( response , userId ) ; set ( credential ) ; } finally { mUIController . stop ( ) ; } } } ; submitTaskToExecutor ( task ) ; return task ; }
Authorizes the Android application to access user's protected data using
the Explicit Authorization Code flow in OAuth 2.0.

@param userId user ID or {@code null} if not using a persisted credential
store
@param callback Callback to invoke when the request completes,
{@code null} for no callback
@param handler {@link Handler} identifying the callback thread,
{@code null} for the main thread
@return An {@link OAuthFuture} which resolves to a {@link Credential}