Skip to content

Basic Authentication

BasicAuthStep executes authentication and registration on the server specified by the onboardingSettings.

The iOS equivalent is BasicAuthentication.swift for onboard, restore, and reset methods.

Input Parameters

Mandatory input parameters:

  • onboardingParameters – This setting is provided on the flowContext typically by the WelcomeScreenStep.

  • context – Specifies the android context initiating the flow such as the caller Activity. This setting has to be provided on the initial FlowContext.

Optional Input Parameters:

  • basicAuthStepStore (provided on the step) – Optional store implementation in order to persist the user credentials.

  • authenticator (provided on the step) – Optional custom okhttp authenticator.

Output parameters

The output is written into the cookie store and into the optional credential store. In addition, an okhttp client is created, which can be accessed through the getOkHttpClient method of the OnboardingContext.

Using BasicAuthStep

  1. Set the context and the onboarding settings in the flowContext.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
      flowContext.setContext(callerActivity);
      try {
                OnboardingParameters onboardingParameters = new OnboardingParameters();
                onboardingParameters.setUrl(SERVICE_URL);
                onboardingParameters.setApplicationId(APPLICATION_ID);
                onboardingParameters.setApplicationVersion(APPLICATION_VERSION);
                onboardingParameters.build();
                flowContext.setOnboardingParameters(onboardingParameters);
       } catch (MalformedURLException e) {
         //error handling
       }
    
  2. Initiate the step.

    1
      BasicAuthStep basicAuthStep = new BasicAuthStep();
    
  3. Specify the execute method's FlowActionHandler parameter's "onFailure" and "onSuccess" behaviour:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
         flowManagerService.execute(flow, flowContext, new FlowActionHandler() {
                @Override
                public void onFailure(Throwable t) {
                    //set the status, update the caller activity
                }
    
                @Override
                public void onSuccess(FlowContext result) {
                    //set the status, update the caller activity
                    //read the result
                }
             });
    

Behaviour of BasicAuthStep

The step sends a post message for the server in order to register the app. If there is no valid session in the cookie store of the device then the step displays the transient UI of the foundation layer. This UI consists of a single dialog box where the end user can enter their username and password required for the server authentication.

After the successful authentication, the session cookies are stored in the cookie store and the registration is executed on the server.

In case of the restore scenario, the okhttp client is created again without resending the post message and repeating the authentication. The user credentials are used from the cookie store and/or from the persistent storage (application store).

If the incoming flow context already contains an http client, then this step skips the creation of the new ok http client.

Relationship to Other Steps

BasicAuthStoreStep uses the output of this step in order to store the user credentials in the application store.