Authenticate the patient with the Nabla SDK
Once a Patient is authenticated in your app, you need to authenticate them on Nabla SDK so that they can securely access their data.
You already pass a
SessionTokenProvider during the init process. This function will be called when the Nabla SDK needs to authenticate the Patient. It should return an
accessToken and a
refreshToken from your backend. See server side documentation for more details.
You need to call
setCurrentUserOrThrow with a stable patient id, as long as the patient didn't change (it will be passed as parameter to the
If you want to change patient, you need to call
clearCurrentUser, as it will clear all data related to the previous patient. Then you will be able to call
setCurrentUserOrThrow with the new patient id.
setCurrentUserOrThrow will throw
Note that the
SessionTokenProviderwill be called only when the SDK needs to identify the patient, it won't be instantaneously called after calling
Make sure you call
setCurrentUserOrThrowat least once before calling any other method of the SDK, otherwise a
NablaException.Authentication.UserIdNotSetwill be returned as
Updated 27 days ago