Your site is responsible for the entirety of the user authentication process. This includes the presentation of an interface for login and the maintenance of a session, and for the retrieval and formatting of context data about that user. Please read the section on using the Authentication with the ContextProvider to understand how you can pass authorization information to the Chat SDK.
- You can proactively authenticate your user at page load.
- You can authenticate your user midway through a session using the SetCustomer API.

Authenticating at Page Load
If a user who is already authenticated with your site requests a page that includes ASAPP chat functionality, you can proactively authenticate that user to the ASAPP SDK at page load time. This allows an authenticated user who initiates a chat session to have immediate access to their account details without having to login again. To authenticate a user to the ASAPP Chat SDK on page load, use the ASAPP Load API providing both ContextProvider and CustomerId as additional keys in the Load method. For example:CustomerId
and a ContextProvider
incorporating that user’s Auth
.
When a user opens the ASAPP Chat SDK, they will already be authenticated to the chat client and can access account information within the chat without being asked to login again.
Authenticating Asynchronously
If a user’s authentication credentials are not available at page load time, you can authenticate asynchronously using the ASAPP SetCustomer API. After you’ve retrieved your user’s credentials, you can call the API to authenticate that user with the ASAPP Chat SDK mid-session. You might want to asynchronously authenticate a user to the ASAPP Chat SDK when (for example) that user has just completed a login flow, or if their credentials are retrieved after the page initially loads, or if a session expires and the user needs to reauthenticate. The following sample snippet shows how to call the SetCustomer API:Auth
information remains valid on your backend, any ASAPP Chat SDK actions that require authentication will be properly authenticated.
The SetCustomer method is typically called as part of the UserLoginHandler.See the section on Using the ‘UserLoginHandler’ Method for a complete picture of how you may want to authenticate a user during an ASAPP Chat SDK session.
Using the ‘UserLoginHandler’ Method
