public void startAuthorizationProcess ( final Context context , ResponseListener listener ) { authorizationQueue . add ( listener ) ; //start the authorization process only if this is the first time we ask for authorization if ( authorizationQueue . size ( ) == 1 ) { try { if ( preferences . clientId . get ( ) == null ) { logger . info ( "starting registration process" ) ; invokeInstanceRegistrationRequest ( context ) ; } else { logger . info ( "starting authorization process" ) ; invokeAuthorizationRequest ( context ) ; } } catch ( Throwable t ) { handleAuthorizationFailure ( t ) ; } } else { logger . info ( "authorization process already running, adding response listener to the queue" ) ; logger . debug ( String . format ( "authorization process currently handling %d requests" , authorizationQueue . size ( ) ) ) ; } }
Main method to start authorization process