Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
OAuth 2.0 Authentication for JavaScript Remoting
A Visualforce page that uses OAuth for authentication configures it at the page level, and uses OAuth for all JavaScript remoting requests. Other than configuration, using JavaScript remoting is exactly the same.
1<script type="text/javascript">
2
3 Visualforce.remoting.oauthAccessToken = <access_token>;
4
5 // ...
6</script>oauthAccessToken is an OAuth authentication token obtained by your page’s code. Obtaining and updating an access token is straightforward OAuth, with one addition. JavaScript remoting OAuth authentication requests the “visualforce” scope, so your token must be generated with this or a scope that contains it, including “web” or “full”. Set scope=visualforce (or “web” or “full”) in your OAuth request.
For information about obtaining access tokens, and using OAuth with the Lightning platform, see Authenticating Remote Access Applications and Digging Deeper into OAuth 2.0 in Salesforce in the Salesforce online help.