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:
| Code | Source | Description |
|---|---|---|
NO_ACTIVITY | login, refreshAuthCredentials (Android) | No current Activity available. |
NOT_AVAILABLE | login, refreshAuthCredentials (Android) | Salesforce SDK not initialized. |
LOGIN_FAILED | login (Android) | No credentials obtained after login flow. |
REFRESH_FAILED | refreshAuthCredentials (Android) | No credentials available after refresh. |
ERROR | Various (Android) | General error with message. |
| Function | iOS | Android |
|---|---|---|
isEmployeeAgentAuthSupported() | Yes (with WithMobileSDK) | Yes (with SalesforceReact) |
loginForEmployeeAgent() | Yes | Yes |
logoutEmployeeAgent() | Yes | Yes |
getEmployeeAgentCredentials() | Yes | Yes |
refreshEmployeeAgentCredentials() | Yes | Yes |
| Export | Type | Description |
|---|---|---|
EMPLOYEE_AGENT_ENABLED | boolean | Whether Employee Agent is enabled |
EMPLOYEE_AGENT_CONFIG | EmployeeAgentConfig | The Employee Agent configuration |
isEmployeeAgentConfigValid | () => boolean | Returns true if the config has required fields |