Authenticating Using the Salesforce Mobile SDK

These instructions describe how to authenticate the Service Chat SDK using the provided authentication mechanism within the Salesforce Mobile SDK.

The legacy chat product is scheduled for retirement on February 14, 2026, and is in maintenance mode until then. During this phase, you can continue to use chat, but we no longer recommend that you implement new chat channels. To avoid service interruptions to your customers, migrate to Messaging for In-App and Web before that date. Messaging offers many of the chat features that you love plus asynchronous conversations that can be picked back up at any time. Learn about chat retirement in Help.

Before starting, make sure that you’ve already:

When creating a connected app, be sure that it has access to the chatter_api scope. See Scope Parameter Values.

  1. If you’re using a Salesforce Experience Cloud site, be sure to configure the login endpoint as described in the Salesforce Mobile SDK documentation (Configure the Login Endpoint).

    The documentation describes how to use the first server listed in your servers.xml file as the default login location. For example:

  2. Add an account_type property to strings.xml. The property must be unique to your app to prevent conflicts with other apps that use the Service Chat SDK or the Salesforce Mobile SDK.

  3. Implement AuthenticatedUser as a wrapper to your Mobile SDK user.

    In Java:

    In Kotlin:

    AuthenticatedUser.getUserId must return the Salesforce user ID (UserAccount.getUserId) for the Case Management message feed to display correctly.

  4. Implement AuthTokenProvider as a wrapper to your Mobile SDK authentication system.

    In Java:

    In Kotlin:

  5. When your app launches, initialize the Salesforce Mobile SDK.

    For more information, see the SalesforceSDKManager documentation in the Mobile SDK Developer’s Guide.

  6. Write code that allows a user to log in and log out of their org using the Salesforce Mobile SDK. Make sure the user logs in before showing the Service Chat SDK UI.

    For example:

  7. When configuring Knowledge (using KnowledgeConfiguration) or Case Management (using CaseConfiguration), use the withAuthConfig method in the builder and pass in your implementation for AuthenticatedUser and AuthTokenProvider.

    This code sample illustrates how it works with Knowledge:

    This code sample illustrates how it works with Case Management:

At this point, you can use the features of the Service Chat SDK as an authenticated user.