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 conversations.

You need to call authenticate with:

  • The Patient id: it should be stable as long as the Patient didn't change (it will be passed as parameter to the SessionTokenProvider)
  • A SessionTokenProvider: A function that 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.


Note that the SessionTokenProvider will be called only when the SDK needs to identify the patient, it won't be instantaneously called after calling authenticate.

launch {
        userId = yourUserId,
        sessionTokenProvider = { userId ->
            // this is a suspending context: call your server to fetch fresh authentication tokens


Make sure you call authenticate before calling any other method of the SDK, otherwise a NablaException.Authentication.NotAuthenticated will be returned as Result.