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:
- Installed the Service Chat SDK. See Install the Service SDK for Android.
- Installed the Salesforce Mobile SDK. If you want to install this SDK using maven, add a dependency on
com.salesforce.mobilesdk:SalesforceSDK:<VERSION_NUMBER>to your module’sbuild.gradlefile. - Created a connected app that allows the SDK to authenticate with your Salesforce Experience Cloud site. See Connected Apps. For an overview of Salesforce authentication from a mobile device, see Understand Security and Authentication.
When creating a connected app, be sure that it has access to the chatter_api scope. See Scope Parameter Values.
-
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.xmlfile as the default login location. For example: -
Add an
account_typeproperty tostrings.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. -
Implement
AuthenticatedUseras a wrapper to your Mobile SDK user.In Java:
In Kotlin:
AuthenticatedUser.getUserIdmust return the Salesforce user ID (UserAccount.getUserId) for the Case Management message feed to display correctly. -
Implement
AuthTokenProvideras a wrapper to your Mobile SDK authentication system.In Java:
In Kotlin:
-
When your app launches, initialize the Salesforce Mobile SDK.
For more information, see the SalesforceSDKManager documentation in the Mobile SDK Developer’s Guide.
-
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:
-
When configuring Knowledge (using
KnowledgeConfiguration) or Case Management (usingCaseConfiguration), use thewithAuthConfigmethod in the builder and pass in your implementation forAuthenticatedUserandAuthTokenProvider.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.