---
schema_version: "1"
id: 43a90480921271dbfe63eb6c3f11bb48d8293134ac03e226fd1f029f9d78461e
title: OAuth 2.0 Authentication for JavaScript Remoting
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/javascript/pages-js-remoting-oauth.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-js-remoting-oauth.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2569f74a5bc7a058711fb82308dd1dc22b1a62836d49423f7817659a80f1c8cc
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# OAuth 2.0 Authentication for JavaScript Remoting

You can use OAuth 2.0 to authenticate JavaScript remoting requests, instead of requiring a standard username and password login process. OAuth allows cross-application and cross-organization integrations that aren’t possible to do securely with standard authentication.

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.

Configuring OAuth for JavaScript remoting from a Visualforce page takes the following form:

```visualforce
<script type="text/javascript">

    Visualforce.remoting.oauthAccessToken = <access_token>;

    // ...
</script>
```

Once `oauthAccessToken` is set, all JavaScript remoting requests use OAuth. The rest of your JavaScript remoting code can remain the same.

`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](https://help.salesforce.com/apex/HTViewHelpDoc?id=remoteaccess_authenticate.htm&language=en_US) and [Digging Deeper into OAuth 2.0 in Salesforce](https://help.salesforce.com/articleView?id=remoteaccess_authenticate_overview.htm) in the Salesforce online help.

