public OAuthFuture < Credential > authorizeImplicitly ( 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 TokenResponseException , Exception { try { LOGGER . info ( "authorizeImplicitly" ) ; Credential credential = mFlow . loadCredential ( userId ) ; if ( credential != null && credential . getAccessToken ( ) != null && ( credential . getRefreshToken ( ) != null || credential . getExpiresInSeconds ( ) == null || credential . getExpiresInSeconds ( ) > 60 ) ) { set ( credential ) ; return ; } String redirectUri = mUIController . getRedirectUri ( ) ; BrowserClientRequestUrl authorizationUrl = mFlow . newImplicitAuthorizationUrl ( ) . setRedirectUri ( redirectUri ) ; mUIController . requestAuthorization ( authorizationUrl ) ; ImplicitResponseUrl implicitResponse = mUIController . waitForImplicitResponseUrl ( ) ; credential = mFlow . createAndStoreCredential ( implicitResponse , userId ) ; set ( credential ) ; } finally { mUIController . stop ( ) ; } } } ; // run the task in a background thread submitTaskToExecutor ( task ) ; return task ; }
Authorizes the Android application to access user s protected data using the Implicit Authorization flow in OAuth 2 . 0 .