---
schema_version: "1"
id: 36abd9268ed384edc3c72cd58b1ebddf8ea82eff9d57cd231592883675d112bc
title: Authentication Reference - React Native
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/genai/agentforce-mobile-sdk/references/react-native/authentication-overview-react-native.md
canonical_url: https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/references/agentforce-mobile-sdk/authentication-overview-react-native.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: ac987e0819a04b0f40fe7b60656c527a5b3223df94693b1591819c0805592c25
products:
  - Agentforce Mobile SDK
  - Agentforce and Einstein Generative AI
---
# Authentication Reference - React Native

Reference documentation for authentication types and functions in the Agentforce Mobile SDK for React Native.

## Overview

Authentication functions are exported directly from the package (not on the `AgentforceService` singleton):

```tsx
import {
  isEmployeeAgentAuthSupported,
  isEmployeeAgentAuthReady,
  hasEmployeeAgentSession,
  loginForEmployeeAgent,
  logoutEmployeeAgent,
  getEmployeeAgentCredentials,
  refreshEmployeeAgentCredentials,
} from "@salesforce/react-native-agentforce";
```

## Auth Functions

These functions manage Employee Agent authentication.

### isEmployeeAgentAuthSupported()

```tsx
async function isEmployeeAgentAuthSupported(): Promise<boolean>;
```

Returns `true` if Mobile SDK auth bridge is available in this build.

### isEmployeeAgentAuthReady()

```tsx
async function isEmployeeAgentAuthReady(): Promise<boolean>;
```

Returns `true` if the user has valid credentials (active session).

### hasEmployeeAgentSession()

```tsx
async function hasEmployeeAgentSession(): Promise<boolean>;
```

Alias for `isEmployeeAgentAuthReady()`. Returns `true` if the user is currently logged in.

### loginForEmployeeAgent()

```tsx
async function loginForEmployeeAgent(): Promise<AuthCredentials>;
```

Launch the Mobile SDK OAuth login flow. Resolves with credentials on success.

**Throws**: Error if auth bridge unavailable, user cancels, or login fails.

### logoutEmployeeAgent()

```tsx
async function logoutEmployeeAgent(): Promise<void>;
```

Log out the current user via Mobile SDK. No-op if bridge unavailable.

### getEmployeeAgentCredentials()

```tsx
async function getEmployeeAgentCredentials(): Promise<AuthCredentials | null>;
```

Get current credentials if logged in; `null` otherwise.

### refreshEmployeeAgentCredentials()

```tsx
async function refreshEmployeeAgentCredentials(): Promise<AuthCredentials>;
```

Force a token refresh via Mobile SDK.

**Throws**: Error with `REFRESH_FAILED`, `NOT_AVAILABLE`, or `NO_ACTIVITY`.

## AuthCredentials

```tsx
interface AuthCredentials {
  instanceUrl: string; // Salesforce instance URL
  organizationId: string; // Org ID
  userId: string; // User ID
  accessToken: string; // Current OAuth access token
  refreshToken?: string; // Refresh token (may not be available on all platforms)
}
```

## Error Codes

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.               |

## Platform Availability

| Function                            | iOS                      | Android                    |
| ----------------------------------- | ------------------------ | -------------------------- |
| `isEmployeeAgentAuthSupported()`    | Yes (with WithMobileSDK) | Yes (with SalesforceReact) |
| `loginForEmployeeAgent()`           | Yes                      | Yes                        |
| `logoutEmployeeAgent()`             | Yes                      | Yes                        |
| `getEmployeeAgentCredentials()`     | Yes                      | Yes                        |
| `refreshEmployeeAgentCredentials()` | Yes                      | Yes                        |

## Employee Agent Config Exports

```tsx
import {
  EMPLOYEE_AGENT_ENABLED,
  EMPLOYEE_AGENT_CONFIG,
  isEmployeeAgentConfigValid,
} from "@salesforce/react-native-agentforce";
```

| 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 |

## See Also

- [Employee Agent Authentication Guide](/docs/ai/agentforce-mobile-sdk/guide/react-native/agentforce-mobile-sdk-react-native-employee-auth)
- [Configuration Reference](https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/references/agentforce-mobile-sdk/configuration-overview-react-native.md)
