Newer Version Available

This content describes an older version of this product. View Latest

Headless Login JavaScript Examples

Use these high-level examples to understand how to implement headless login for a single-page app.

Authorization Request

The Authorization Code and Credentials Flow enables users to log in with a username and password. A core concept of this flow is making an authorization request to Headless Login API. This client-side JavaScript example shows you how to send an authorization request.

Token Exchange

After receiving the authorization request, Salesforce validates the username and password and returns an authorization code. The app then calls the token endpoint to exchange the code for an access token. This client-side JavaScript example shows the token exchange.

The result is an access token that you can use to request user information and establish the user’s session.