Authentication from Lightning Out (Beta)
We recommend using Lightning Out 2.0 instead of Lightning Out (beta). Lightning Out 2.0 is a new generally available feature that completely replaces–and isn’t an extension of–Lightning Out (beta), which is still subject to Beta Service Terms. See How Lightning Out 2.0 Compares to Lightning Out (Beta).
To handle authentication, you must manually provide a Salesforce session ID or an OAuth access token when you initialize a Lightning Out (beta) app.
There are two supported ways to handle authentication for Lightning Out (beta).
- Use a Salesforce session ID. For example, on a Visualforce page, you can obtain the current Visualforce session ID with the expression
{! $Api.Session_ID }
. Sessions initiated with this session ID are intended for use only on Visualforce pages. - Use an OAuth access token. Follow the same process that's used to authorize client applications that access Salesforce REST API resources. See Authorization Through Connected Apps and OAuth 2.0 in the REST API Developer Guide.
Lightning Out (beta) doesn't support JSON Web Tokens (JWT)-based access tokens. When implementing an OAuth authorization flow, use opaque access tokens instead.
Lightning Out (beta) has the same privileges as the session from which you obtain the authentication token. If you use a Salesforce session ID, the session has the privileges of the current user. If you use an OAuth access token, the privilege is defined when you create the connected app. Usually, Lightning Out (beta) requires you to grant Full Access scope to the connected app returning the OAuth access token.
A Lightning Out (beta) authenticated session persists access to any lightning.force.com
domain running in the active browser session. After a user is authenticated, the session credentials are validated across all Salesforce applications running in the active browser session.
To prevent session persistence, Salesforce admins can lock the session to the originating IP address. From Setup, in the Quick Find box, enter Session Settings
, and then select Session Settings. Then select Lock sessions to the IP address from which they originated.
See Also
- Use Components in Visualforce Pages
- Enable Browser Third-Party Cookies for Lightning Out (beta)
- Salesforce Help: Enable OAuth Settings for API Integration