Developer

Registering Devices and Connecting Users

Register a device and log on a user using LogonCore and SecureStore library calls.

Prerequisites

Define the application and client password policy in SAP Mobile Platform Server using the cockpit.

Procedure

  1. Initialize the logonCore variable:
    var logonCore = await 
    SAP.Logon.Core.LogonCore.InitWithApplicationIdAsync("com.sap.windows.flight");  
  2. Register the device by calling RegisterWithContextAsync. This sends an HTTP POST request to the SAP Mobile Platform Server with a payload to identify the device to the SAP Mobile Platform Server, which then registers the device and sends back the registration information as part of the response:
    var logonContext = new SAP.Logon.Core.LogonContext
    
    await logonCore.RegisterWithContextAsync(logonContext); 
    {
        RegistrationContext = new SAP.Logon.Core.RegistrationContext
        {
            ApplicationId = “App Id", ServerHost = “IP Address Or Hostname", IsHttps = false, 
            ServerPort = 8080
        }
    };
  3. Persist locally all registration information received from SAP Mobile Platform Server:
    await logonCore.PersistRegistrationAsync(passcode, logonContext);  
    The passcode is an arbitrarily chosen password that is eligible for the passcode policy sent back by the server.
  4. Store the application connection ID after logon:
    var connectionId = logonCore.ApplicationSettings.ApplicationConnectionId;