Authentication Reference - React Native

Reference documentation for authentication types and functions in the Agentforce Mobile SDK for React Native.

Authentication functions are exported directly from the package (not on the AgentforceService singleton):

These functions manage Employee Agent authentication.

Returns true if Mobile SDK auth bridge is available in this build.

Returns true if the user has valid credentials (active session).

Alias for isEmployeeAgentAuthReady(). Returns true if the user is currently logged in.

Launch the Mobile SDK OAuth login flow. Resolves with credentials on success.

Throws: Error if auth bridge unavailable, user cancels, or login fails.

Log out the current user via Mobile SDK. No-op if bridge unavailable.

Get current credentials if logged in; null otherwise.

Force a token refresh via Mobile SDK.

Throws: Error with REFRESH_FAILED, NOT_AVAILABLE, or NO_ACTIVITY.

Error codes thrown by the EmployeeAgentAuthBridge:

CodeSourceDescription
NO_ACTIVITYlogin, refreshAuthCredentials (Android)No current Activity available.
NOT_AVAILABLElogin, refreshAuthCredentials (Android)Salesforce SDK not initialized.
LOGIN_FAILEDlogin (Android)No credentials obtained after login flow.
REFRESH_FAILEDrefreshAuthCredentials (Android)No credentials available after refresh.
ERRORVarious (Android)General error with message.
FunctioniOSAndroid
isEmployeeAgentAuthSupported()Yes (with WithMobileSDK)Yes (with SalesforceReact)
loginForEmployeeAgent()YesYes
logoutEmployeeAgent()YesYes
getEmployeeAgentCredentials()YesYes
refreshEmployeeAgentCredentials()YesYes
ExportTypeDescription
EMPLOYEE_AGENT_ENABLEDbooleanWhether Employee Agent is enabled
EMPLOYEE_AGENT_CONFIGEmployeeAgentConfigThe Employee Agent configuration
isEmployeeAgentConfigValid() => booleanReturns true if the config has required fields