{"id":20256,"date":"2024-08-30T07:00:19","date_gmt":"2024-08-30T05:00:19","guid":{"rendered":"https:\/\/numericaideas.com\/?p=20256"},"modified":"2025-01-07T04:42:13","modified_gmt":"2025-01-07T03:42:13","slug":"salesforce-oauth2-web-server-flow","status":"publish","type":"post","link":"https:\/\/dassiorleando.com\/fr\/salesforce-oauth2-web-server-flow\/","title":{"rendered":"Salesforce OAuth 2.0 Web Server Flow in NodeJS"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p><strong>Salesforce<\/strong> provides a robust set of APIs that allow developers to interact with their platform programmatically. In this article, we&#8217;ll explore how to build a <strong>Salesforce Connected App<\/strong> for API integration using <strong>Node.js<\/strong>, the <strong>OAuth 2.0 Web Server Flow<\/strong> will be implemented.<\/p>\n\n\n\n<p><strong>This article was originally posted<\/strong>\u00a0on the NumericaIdeas tech community blog: <a href=\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/<\/a><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>The&nbsp;<strong>YouTube Channels<\/strong>&nbsp;in both English (En) and French (Fr) are now accessible, feel free to subscribe by clicking&nbsp;<a href=\"https:\/\/www.youtube.com\/@numericaideas\/channels?sub_confirmation=1\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n<\/blockquote>\n\n\n<div class=\"vlp-link-container vlp-layout-basic wp-block-visual-link-preview-link\"><a href=\"https:\/\/www.youtube.com\/@numericaideas\/channels?sub_confirmation=1\" class=\"vlp-link\" title=\"Numerica Ideas\" rel=\"nofollow\" target=\"_blank\"><\/a><div class=\"vlp-layout-zone-side\"><div class=\"vlp-block-2 vlp-link-image\"><img decoding=\"async\" src=\"https:\/\/yt3.googleusercontent.com\/klwPa3fnccvxnvUjmfGmcdJDeX8J7BMbRraxiH69WeLx6qr3fQdxYSGN37vKE4jBCqGX5pZCgQ=s900-c-k-c0x00ffffff-no-rj\" style=\"max-width: 150px; max-height: 150px\" \/><\/div><\/div><div class=\"vlp-layout-zone-main\"><div class=\"vlp-block-0 vlp-link-title\">Numerica Ideas<\/div><div class=\"vlp-block-1 vlp-link-summary\">NumericaIdeas is a technical community that creates opportunities for IT professionals, where you\u2019ll secure your dream job, and indeed the group through which you can develop your hard and soft skills at your own pace. Our motto is \u201cDiscover, Learn, Build, &amp; Share\u201d \ud83d\ude80 \ud83d\udca1 La cha\u00eene est aussi disponi\u2026<\/div><\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>The goal is to grant API access to a Salesforce account without providing any username and password pair, so this tutorial assumes you are familiar with <a href=\"https:\/\/numericaideas.com\/blog\/what-is-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">Salesforce<\/a>, the <a href=\"https:\/\/en.wikipedia.org\/wiki\/OAuth\">OAuth<\/a> authorization protocol, and NodeJS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Salesforce OAuth 2.0 Web Server Flow<\/h2>\n\n\n\n<p>The OAuth 2.0 flow is simple, and here are the authorization steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The user wants to connect his Salesforce account.<\/li>\n\n\n\n<li>We send him an authentication URL to log himself into Salesforce.<\/li>\n\n\n\n<li>Once logged in, Salesforce sends us a code to the callback.<\/li>\n\n\n\n<li>We exchange that code to have an <strong>access token<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p>The <strong>access token<\/strong> can then be used as the <strong>authorization bearer<\/strong> token for any protected Salesforce API resources we would like to access.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Salesforce Connected App<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Basic Info<\/h4>\n\n\n\n<p>It&#8217;s straightforward to create a Salesforce Connected App, let&#8217;s follow the below instructions:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to your Salesforce Developer account.<\/li>\n\n\n\n<li>Navigate to <strong>Setup<\/strong> on the top right, then search for the <strong>App Manager<\/strong> in the Quick Find box.<\/li>\n\n\n\n<li>Click on the <strong>New Connected App<\/strong> button.<\/li>\n<\/ol>\n\n\n\n<p>You&#8217;ll have a page similar to the following, in which you have to provide your App basic info (App Name, API Name, and Contact Email):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/numericaideas.com\/wp-content\/uploads\/2024\/01\/salesforce-connected-app-basic-info-required-1300x635.png\" alt=\"\" class=\"wp-image-20258\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">OAuth Settings<\/h4>\n\n\n\n<p>Just down to the <strong>Basic Information<\/strong> area, you have the <strong>API (Enable OAuth Settings)<\/strong> panel, from there let&#8217;s enable<strong> OAuth Settings<\/strong>.<\/p>\n\n\n\n<p>This section is crucial for Salesforce to know more about the integration you are building, so let&#8217;s provide more details as follows and click <strong>Save<\/strong> then <strong>Continue<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>The callback URL<\/strong>:  This is a server URL called once the end-user is granted access to his <strong>Salesforce<\/strong> account via the OAuth flow. Let&#8217;s provide a secured URL since sensitive information will flow to it to complete the authorization mechanism.<\/li>\n\n\n\n<li><strong>OAuth scopes<\/strong>: It&#8217;s the permissions your API requests access for, do remember to always select ONLY what you need to apply the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Principle_of_least_privilege\">principle of the least privilege<\/a>. This means that if this integration is attacked by hackers, your whole Salesforce account won&#8217;t be at risk, but only the scopes specified.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/numericaideas.com\/wp-content\/uploads\/2024\/01\/salesforce-connected-app-oauth-settings-1300x689.png\" alt=\"salesforce connected app oauth settings\" class=\"wp-image-20260\"\/><\/figure>\n\n\n\n<p>The scopes selected are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Access unique user identifiers (openid)<\/strong>: This scope allows the connected App to access the logged-in user\u2019s unique identifier.<\/li>\n\n\n\n<li><strong>Manage user data via APIs (api):<\/strong> This scope allows access to the current, logged-in user\u2019s account using APIs, such as REST API and Bulk API. This value also includes access to Chatter REST API resources, so you may not need to select the <strong>chatter_api<\/strong> scope.<\/li>\n\n\n\n<li><strong>Manage user data via Web browsers (web)<\/strong>: This scope allows the app to use the access token on the web and allows access to customer-created Visualforce pages.<\/li>\n<\/ul>\n\n\n\n<p><strong>Note<\/strong>: we&#8217;ll change our callback URL once the NodeJS backend is deployed and accessible online.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Manage Consumer Details<\/h4>\n\n\n\n<p>From the <strong>Manage Connected Apps<\/strong> page, click on the Manage Consumer Details button, then copy your connected App <strong>consumer key<\/strong> and <strong>consumer secret<\/strong> for later use in a NodeJS project.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Salesforce OAuth 2.0 Integration in NodeJS<\/h3>\n\n\n\n<p>By this stage, you should have the connected App&#8217;s consumer key (client ID), consumer secret (client secret), and the callback URL (redirect URI).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Handle Sensible Credentials<\/h4>\n\n\n\n<p>Since the first two are sensible information, you should use a method like the one performed by the <a href=\"https:\/\/www.npmjs.com\/package\/dotenv\" target=\"_blank\" rel=\"noreferrer noopener\">dotenv<\/a> package to hide it from your source code at the deployment stage.<\/p>\n\n\n\n<p>Feel free to install <a href=\"https:\/\/www.npmjs.com\/package\/dotenv\">dotenv<\/a> using the command <code>npm install -S dotenv<\/code> and set it up in your main file like below:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">require('dotenv').config();<\/pre>\n\n\n\n<p>Once done, we can create a <strong>.env<\/strong> file in our project, we have created a template for it called <a href=\"https:\/\/github.com\/numerica-ideas\/community\/blob\/master\/salesforce\/oauth2-web-server-flow\/.env.sample\" target=\"_blank\" rel=\"noreferrer noopener\">.env.sample<\/a> whose content is below:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">APP_DOMAIN=https:\/\/xxxx-yyyy-zzzz.ngrok-free.app   # Localhost is not secured, deploy your backend online or try ngrok\nSF_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nSF_CLIENT_SECRET=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<\/pre>\n\n\n\n<p>Do remember to change the values with the ones of your connected App you created in the previous step.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Request an Authorization Code<\/h4>\n\n\n\n<p>For the OAuth flow to work, two important endpoints must be created on the NodeJS side, one that sends back the authentication URL that the user will follow to grant access to its Salesforce account, and the last is the callback that Salesforce will send sensitive info to once the access is granted.<\/p>\n\n\n\n<p>Let&#8217;s install the <a href=\"https:\/\/github.com\/jsforce\/jsforce\" target=\"_blank\" rel=\"noreferrer noopener\">jsforce<\/a> package that we&#8217;ll use to make the process easier, it&#8217;s a JavaScript library that interacts with Salesforce&#8217;s API.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">npm install jsforce -S<\/pre>\n\n\n\n<p>Let&#8217;s use our Salesforce connected App to set up an OAuth2 instance now:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">const oauth2 = new jsforce.OAuth2({\n  \/\/ you can change loginUrl to connect to sandbox or prerelease env.\n  \/\/   loginUrl : 'https:\/\/test.salesforce.com',\n  clientId: process.env.SF_CLIENT_ID,\n  clientSecret: process.env.SF_CLIENT_SECRET,\n  redirectUri: `${process.env.APP_DOMAIN}\/callback`,\n});<\/pre>\n\n\n\n<p>By using an Express server, here&#8217;s the authentication URL endpoint:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">app.get(\"\/auth\", function (req, res) {\n  const authURL = oauth2.getAuthorizationUrl({\n    scope: \"api web openid chatter_api refresh_token\",\n  });\n  res.redirect(authURL);\n});<\/pre>\n\n\n\n<p><strong>Note<\/strong>: Make sure to provide the scopes (permissions) that your connected App has access to, especially the ones your NodeJS App needs, or else the next use of that OAuth2 instance won&#8217;t work properly.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Request an Access Token<\/h4>\n\n\n\n<p>Once the connected App is approved, Salesforce sends back the authorization code requested in the previous step.<\/p>\n\n\n\n<p>The callback endpoint to complete the authorization process by processing that code is below:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">\/\/ Pass the received authorization code and get access token\napp.get(\"\/callback\", function (req, res) {\n  const conn = new jsforce.Connection({ oauth2 });\n  const code = req.query.code;\n  conn.authorize(code, function (error, userInfo) {\n    if (error) {\n      console.error(error);\n      return res.status(400).send(error);\n    }\n    \/\/ Don't log sensible info in a production setup, this is just for illustration\n    \/\/ Now you have the access token, refresh token, and instance URL info\n    \/\/ Save them in the db or cache for later use\/connection\n    console.log(conn.accessToken);\n    console.log(conn.refreshToken);\n    console.log(conn.instanceUrl);\n    console.log(\"User ID: \" + userInfo.id);\n    console.log(\"Org ID: \" + userInfo.organizationId);\n    res.send(\"success\");\n  });\n});<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Salesforce API Requests in NodeJS<\/h3>\n\n\n\n<p>The jsforce library uses the <strong>access token<\/strong> to call Salesforce API resources on behalf of the logged-in user, it simplifies the API integration, read more <a href=\"https:\/\/jsforce.github.io\/document\/\">here<\/a>.<\/p>\n\n\n\n<p>In our case, we simply wrote a message in <strong>Chatter<\/strong> by creating another endpoint like below:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">app.get(\"\/chatter\", function (req, res) {\n  \/\/ Get the logged-in user's access\/refresh token from the db or cache\n  const conn = new jsforce.Connection({ oauth2, instanceUrl: 'savedInstanceUrl', accessToken: 'savedAccessToken', refreshToken: 'savedRefreshToken' });\n  \/\/ Let's write in Chatter to test it out\n  conn.chatter.resource(\"\/feed-elements\").create(\n    {\n      body: {\n        messageSegments: [\n          {\n            type: \"Text\",\n            text: \"This is a NEW post\",\n          },\n        ],\n      },\n      feedElementType: \"FeedItem\",\n      subjectId: \"me\",\n    },\n    function (error, result) {\n      if (error) {\n        console.error(error);\n        return res.status(400).send(error);\n      }\n      console.log(\"New comment of id: \" + result.id);\n      res.send(\"OK\");\n    }\n  );\n  conn.on(\"refresh\", function (accessToken, res) {\n    \/\/ Refresh event will be fired when renewed access token\n    \/\/ TODO: do something here with the new access token: save it again\n    console.log(\"Access token refreshed: \" + accessToken);\n  });\n});<\/pre>\n\n\n\n<p><strong>The full <a href=\"https:\/\/github.com\/numerica-ideas\/community\/tree\/master\/salesforce\/oauth2-web-server-flow\" target=\"_blank\" rel=\"noreferrer noopener\">source code<\/a> is available on <a href=\"https:\/\/github.com\/numerica-ideas\/community\/tree\/master\/salesforce\/oauth2-web-server-flow\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a>.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test<\/h3>\n\n\n\n<p>If you test it now, it won&#8217;t work because the NodeJS App isn&#8217;t yet linked with your connected App, because we have to fix the callback URL.<\/p>\n\n\n\n<p>First, deploy your NodeJS backend using the domain where it&#8217;s located in the <strong>APP_DOMAIN<\/strong> environment variable present in the <strong>.env<\/strong> file.<\/p>\n\n\n\n<p>Second, you have to change your Salesforce connected App settings to use the right callback URL: <strong>{APP_DOMAIN}\/callback<\/strong>.<\/p>\n\n\n\n<p>Finally, use another account to connect yourself to your App by following the <strong>OAuth2<\/strong> process described above. The entry point is <strong>{APP_DOMAIN}\/auth<\/strong>.<\/p>\n\n\n\n<p>By testing everything, our <a href=\"https:\/\/github.com\/numerica-ideas\/community\/tree\/master\/salesforce\/oauth2-flow\">NodeJS project<\/a> <strong><strong>{APP_DOMAIN}<\/strong>\/chatter<\/strong> API endpoint output is:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1207\" height=\"535\" src=\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/salesforce-connected-app-test-chatter.png\" alt=\"Salesforce connected App Chatter API test\" class=\"wp-image-20277\" srcset=\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/salesforce-connected-app-test-chatter.png 1207w, https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/salesforce-connected-app-test-chatter-300x133.png 300w, https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/salesforce-connected-app-test-chatter-1024x454.png 1024w, https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/salesforce-connected-app-test-chatter-768x340.png 768w\" sizes=\"(max-width: 1207px) 100vw, 1207px\" \/><\/figure>\n\n\n\n<p>Do you want to know more about Salesforce? Take a look at the <a href=\"https:\/\/numericaideas.com\/blog\/what-is-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">What is Salesforce?<\/a> article that we released recently:<\/p>\n\n\n<div class=\"vlp-link-container vlp-layout-basic wp-block-visual-link-preview-link\"><a href=\"https:\/\/numericaideas.com\/blog\/what-is-salesforce\/\" class=\"vlp-link\" title=\"What is Salesforce?\" rel=\"nofollow\" target=\"_blank\"><\/a><div class=\"vlp-layout-zone-side\"><div class=\"vlp-block-2 vlp-link-image\"><img decoding=\"async\" src=\"https:\/\/assets.numericaideas.com\/2024\/01\/What-is-Salesforce.png\" style=\"max-width: 150px; max-height: 150px\" \/><\/div><\/div><div class=\"vlp-layout-zone-main\"><div class=\"vlp-block-0 vlp-link-title\">What is Salesforce?<\/div><div class=\"vlp-block-1 vlp-link-summary\">Building and maintaining strong relationships with customers is essential to success. This is where Salesforce, a Customer Relationship Management (CRM) solutions giant, comes in.<\/div><\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting Salesforce OAuth 2.0<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Error mismatch<\/strong>: The consumer key, consumer secret, and callback URL you use in NodeJS should match what is present in the Salesforce App manager.<\/li>\n\n\n\n<li>If you get the error <strong>&#8220;1800 : There was a problem in setting up your remote access&#8221;<\/strong>, make sure the connected App you created and the user testing your App are both in the same environment.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/jsforce\/jsforce\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/jsforce\/jsforce<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/help.salesforce.com\/s\/articleView?id=sf.remoteaccess_oauth_web_server_flow.htm&amp;type=5\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/help.salesforce.com\/s\/articleView?id=sf.remoteaccess_oauth_web_server_flow.htm&amp;type=5<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/help.salesforce.com\/s\/articleView?id=sf.remoteaccess_oauth_tokens_scopes.htm&amp;type=5\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/help.salesforce.com\/s\/articleView?id=sf.remoteaccess_oauth_tokens_scopes.htm&amp;type=5<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/numerica-ideas\/community\/tree\/master\/salesforce\/oauth2-web-server-flow\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/numerica-ideas\/community\/tree\/master\/salesforce\/oauth2-web-server-flow<\/a><a href=\"\"><\/a><\/li>\n<\/ul>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\"><strong>Let&#8217;s note that the jsforce npm package has a few basic maintenance commits over a long period and was maintained by only 1 person, so not sure you may receive great support if anything goes wrong in it &#8230; but there&#8217;s a great promise that way, as one of the Salesforce teams started to contribute to push jsforce forward since a lot of Salesforce open source tools rely on the jsforce package, here&#8217;s the official <a href=\"https:\/\/github.com\/jsforce\/jsforce\/issues\/1360\" target=\"_blank\" rel=\"noreferrer noopener\">announcement<\/a>.<\/strong><\/mark><\/p>\n\n\n\n<p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n\n\n\n<p>We have just started our journey to build a network of professionals to grow even more our free knowledge-sharing community that will give you a chance to learn interesting things about topics like cloud computing, software development, and software architectures while keeping the door open to more opportunities.<\/p>\n\n\n\n<p>Does this speak to you? If <strong>YES<\/strong>, feel free to <a href=\"https:\/\/discord.numericaideas.com\">Join our Discord Server<\/a> to stay in touch with the community and be part of independently organized events.<\/p>\n\n\n\n<p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In summary, this article unveiled the steps to securely integrate Salesforce with your NodeJS projects by using the OAuth 2.0 Web Server Flow by requesting an authorization code, allowing the user to approve the App, and then requesting the access token for later use in API requests.<\/p>\n\n\n\n<p>Thanks for reading this article. Like, recommend, and share if you enjoyed it. Follow us on <a href=\"https:\/\/www.facebook.com\/numericaideas\" rel=\"nofollow\">Facebook<\/a>, <a href=\"https:\/\/twitter.com\/numericaideas\" rel=\"nofollow\">Twitter<\/a>, and <a href=\"https:\/\/www.linkedin.com\/company\/numericaideas\" rel=\"nofollow\">LinkedIn<\/a> for more content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we&#8217;ll explore how to build a Salesforce Connected App for API integration using Node.js, the OAuth 2.0 Web Server Flow will be implemented.<\/p>","protected":false},"author":2,"featured_media":20335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[38,60],"class_list":["post-20256","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-crm","tag-nodejs","tag-salesforce"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Salesforce OAuth 2.0 Web Server Flow in NodeJS<\/title>\n<meta name=\"description\" content=\"In this article, we&#039;ll explore how to build a Salesforce Connected App for API integration using Node.js, the OAuth 2.0 Web Server Flow will be implemented.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/\" \/>\n<meta property=\"og:locale\" content=\"fr_CA\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Salesforce OAuth 2.0 Web Server Flow in NodeJS\" \/>\n<meta property=\"og:description\" content=\"In this article, we&#039;ll explore how to build a Salesforce Connected App for API integration using Node.js, the OAuth 2.0 Web Server Flow will be implemented.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/\" \/>\n<meta property=\"og:site_name\" content=\"Orleando Dassi\" \/>\n<meta property=\"article:published_time\" content=\"2024-08-30T05:00:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-07T03:42:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Orl\u00e9ando Dassi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dassiorleando\" \/>\n<meta name=\"twitter:site\" content=\"@dassiorleando\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Orl\u00e9ando Dassi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dassiorleando.com\/salesforce-oauth2-web-server-flow\/\"},\"author\":{\"name\":\"Orl\u00e9ando Dassi\",\"@id\":\"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e\"},\"headline\":\"Salesforce OAuth 2.0 Web Server Flow in NodeJS\",\"datePublished\":\"2024-08-30T05:00:19+00:00\",\"dateModified\":\"2025-01-07T03:42:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dassiorleando.com\/salesforce-oauth2-web-server-flow\/\"},\"wordCount\":1471,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e\"},\"image\":{\"@id\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png\",\"keywords\":[\"NodeJS\",\"Salesforce\"],\"articleSection\":[\"CRM\"],\"inLanguage\":\"fr-CA\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dassiorleando.com\/salesforce-oauth2-web-server-flow\/\",\"url\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/\",\"name\":\"Salesforce OAuth 2.0 Web Server Flow in NodeJS\",\"isPartOf\":{\"@id\":\"https:\/\/dassiorleando.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png\",\"datePublished\":\"2024-08-30T05:00:19+00:00\",\"dateModified\":\"2025-01-07T03:42:13+00:00\",\"description\":\"In this article, we'll explore how to build a Salesforce Connected App for API integration using Node.js, the OAuth 2.0 Web Server Flow will be implemented.\",\"breadcrumb\":{\"@id\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#breadcrumb\"},\"inLanguage\":\"fr-CA\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-CA\",\"@id\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage\",\"url\":\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png\",\"contentUrl\":\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png\",\"width\":1366,\"height\":768,\"caption\":\"NodeJS Salesforce OAuth 2.0 Web Server Flow Integration\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dassiorleando.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Salesforce OAuth 2.0 Web Server Flow in NodeJS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dassiorleando.com\/#website\",\"url\":\"https:\/\/dassiorleando.com\/\",\"name\":\"Orleando Dassi\",\"description\":\"My personal portfolio and resume\",\"publisher\":{\"@id\":\"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dassiorleando.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-CA\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e\",\"name\":\"Orl\u00e9ando Dassi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-CA\",\"@id\":\"https:\/\/dassiorleando.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2025\/01\/Orleando-Dassi-Consultant-Quebec.webp\",\"contentUrl\":\"https:\/\/dassiorleando.com\/wp-content\/uploads\/2025\/01\/Orleando-Dassi-Consultant-Quebec.webp\",\"width\":1643,\"height\":1747,\"caption\":\"Orl\u00e9ando Dassi\"},\"logo\":{\"@id\":\"https:\/\/dassiorleando.com\/#\/schema\/person\/image\/\"},\"description\":\"I'm a Solutions Architect with 10 years of experience who is constantly learning while impacting the community by producing technical articles\/videos, building projects, and conducting tech mentoring\/coaching sessions. What describes me the most is my flexibility.\",\"sameAs\":[\"https:\/\/dassiorleando.com\/\",\"https:\/\/www.instagram.com\/dassiorleando\/\",\"https:\/\/www.linkedin.com\/in\/dassi-orleando-257b04ab\/\",\"https:\/\/x.com\/dassiorleando\",\"https:\/\/www.youtube.com\/@dassiorleando\"],\"url\":\"https:\/\/dassiorleando.com\/fr\/author\/dassiorleando\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Salesforce OAuth 2.0 Web Server Flow in NodeJS","description":"In this article, we'll explore how to build a Salesforce Connected App for API integration using Node.js, the OAuth 2.0 Web Server Flow will be implemented.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/","og_locale":"fr_CA","og_type":"article","og_title":"Salesforce OAuth 2.0 Web Server Flow in NodeJS","og_description":"In this article, we'll explore how to build a Salesforce Connected App for API integration using Node.js, the OAuth 2.0 Web Server Flow will be implemented.","og_url":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/","og_site_name":"Orleando Dassi","article_published_time":"2024-08-30T05:00:19+00:00","article_modified_time":"2025-01-07T03:42:13+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png","type":"image\/png"}],"author":"Orl\u00e9ando Dassi","twitter_card":"summary_large_image","twitter_creator":"@dassiorleando","twitter_site":"@dassiorleando","twitter_misc":{"Written by":"Orl\u00e9ando Dassi","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#article","isPartOf":{"@id":"https:\/\/dassiorleando.com\/salesforce-oauth2-web-server-flow\/"},"author":{"name":"Orl\u00e9ando Dassi","@id":"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e"},"headline":"Salesforce OAuth 2.0 Web Server Flow in NodeJS","datePublished":"2024-08-30T05:00:19+00:00","dateModified":"2025-01-07T03:42:13+00:00","mainEntityOfPage":{"@id":"https:\/\/dassiorleando.com\/salesforce-oauth2-web-server-flow\/"},"wordCount":1471,"commentCount":1,"publisher":{"@id":"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e"},"image":{"@id":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage"},"thumbnailUrl":"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png","keywords":["NodeJS","Salesforce"],"articleSection":["CRM"],"inLanguage":"fr-CA","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dassiorleando.com\/salesforce-oauth2-web-server-flow\/","url":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/","name":"Salesforce OAuth 2.0 Web Server Flow in NodeJS","isPartOf":{"@id":"https:\/\/dassiorleando.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage"},"image":{"@id":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage"},"thumbnailUrl":"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png","datePublished":"2024-08-30T05:00:19+00:00","dateModified":"2025-01-07T03:42:13+00:00","description":"In this article, we'll explore how to build a Salesforce Connected App for API integration using Node.js, the OAuth 2.0 Web Server Flow will be implemented.","breadcrumb":{"@id":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#breadcrumb"},"inLanguage":"fr-CA","potentialAction":[{"@type":"ReadAction","target":["https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/"]}]},{"@type":"ImageObject","inLanguage":"fr-CA","@id":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#primaryimage","url":"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png","contentUrl":"https:\/\/dassiorleando.com\/wp-content\/uploads\/2024\/01\/NodeJS-Salesforce-OAuth-2.0-Web-Server-Flow-Integration.png","width":1366,"height":768,"caption":"NodeJS Salesforce OAuth 2.0 Web Server Flow Integration"},{"@type":"BreadcrumbList","@id":"https:\/\/numericaideas.com\/blog\/salesforce-oauth2-web-server-flow\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dassiorleando.com\/"},{"@type":"ListItem","position":2,"name":"Salesforce OAuth 2.0 Web Server Flow in NodeJS"}]},{"@type":"WebSite","@id":"https:\/\/dassiorleando.com\/#website","url":"https:\/\/dassiorleando.com\/","name":"Orleando Dassi","description":"My personal portfolio and resume","publisher":{"@id":"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dassiorleando.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-CA"},{"@type":["Person","Organization"],"@id":"https:\/\/dassiorleando.com\/#\/schema\/person\/4862911e9cf93aa12f17875f7b7b1c5e","name":"Orl\u00e9ando Dassi","image":{"@type":"ImageObject","inLanguage":"fr-CA","@id":"https:\/\/dassiorleando.com\/#\/schema\/person\/image\/","url":"https:\/\/dassiorleando.com\/wp-content\/uploads\/2025\/01\/Orleando-Dassi-Consultant-Quebec.webp","contentUrl":"https:\/\/dassiorleando.com\/wp-content\/uploads\/2025\/01\/Orleando-Dassi-Consultant-Quebec.webp","width":1643,"height":1747,"caption":"Orl\u00e9ando Dassi"},"logo":{"@id":"https:\/\/dassiorleando.com\/#\/schema\/person\/image\/"},"description":"I'm a Solutions Architect with 10 years of experience who is constantly learning while impacting the community by producing technical articles\/videos, building projects, and conducting tech mentoring\/coaching sessions. What describes me the most is my flexibility.","sameAs":["https:\/\/dassiorleando.com\/","https:\/\/www.instagram.com\/dassiorleando\/","https:\/\/www.linkedin.com\/in\/dassi-orleando-257b04ab\/","https:\/\/x.com\/dassiorleando","https:\/\/www.youtube.com\/@dassiorleando"],"url":"https:\/\/dassiorleando.com\/fr\/author\/dassiorleando\/"}]}},"_links":{"self":[{"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/posts\/20256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/comments?post=20256"}],"version-history":[{"count":5,"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/posts\/20256\/revisions"}],"predecessor-version":[{"id":21944,"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/posts\/20256\/revisions\/21944"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/media\/20335"}],"wp:attachment":[{"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/media?parent=20256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/categories?post=20256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dassiorleando.com\/fr\/wp-json\/wp\/v2\/tags?post=20256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}