Authentication

React Native ==> Session module

Authenticating requests with the Validic API requires a Validic Mobile User to be provisioned and with a Validic Mobile User Token. Further documentation for creating Validic Mobile Users is available in Provisioning and Managing Users .

You will need to provision the user from your server or your mobile app.

Provisioning a User

It is required to use valid Validic user credentials. The validicUserID, organizationID, and accessToken properties will be sent to the Inform server for validation at the start of any user session. Sessions started with invalid or unknown user credentials (i.e. any credentials not provisioned by the Validic API) will be ended automatically and you will not be able to receive data records from the Inform SDK.

It is recommended to provision the user on your server, the mobile app could then authenticate to the server and retrieve the Validic credentials.

import ValidicSession from "react-native-validic-session";

The ValidicSession persists a user across the sdk and all pending record uploads. This data is persisted between app launches but is deleted if the ValidicSession.endSession function is called.

Start Session

A new Session is started by passing previously provisioned Validic user credentials to the startSession function.

try{  
  await ValidicSession.startSession({  
    user_id: USER_ID,  
    org_id: ORGANIZATION_ID,  
    user_token: USER_ACCESS_TOKEN,  
  });  
catch(e){  
  // credentials are empty or missing  
  console.log(e)  
}

The supplied credentials are validated when the session is created. If invalid credentials have been provided the session will be ended. See Record Events for listening for the session ending.

To change credentials end a session and start a new one with the new credentials

ValidicSession.endSession();  
await ValidicSession.startSession(new_user);

or uninstall the app. When a new session is created, pending record uploads and subscriptons are reset. For this reason, a new session should only be created if a session it not already active.

End Session

An end user's session be ended by calling endSession. This will end the client's persisted User and cancel all pending work in the Validic Mobile SDKs. See Record Events for details on how to listen for User Session events.

ValidicSession.endSession();  

Keep in mind the Important Considerations when ending the user session.