<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by BZ on Medium]]></title>
        <description><![CDATA[Stories by BZ on Medium]]></description>
        <link>https://medium.com/@bzaveri?source=rss-179852e5d450------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jUyouYU90KxudGuD.jpg</url>
            <title>Stories by BZ on Medium</title>
            <link>https://medium.com/@bzaveri?source=rss-179852e5d450------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:43:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bzaveri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to get an OAuth token using JWT in Salesforce]]></title>
            <link>https://medium.com/@bzaveri/how-to-get-an-oauth-token-using-jwt-in-salesforce-3600dd2a65de?source=rss-179852e5d450------2</link>
            <guid isPermaLink="false">https://medium.com/p/3600dd2a65de</guid>
            <dc:creator><![CDATA[BZ]]></dc:creator>
            <pubDate>Thu, 11 Jun 2020 02:55:35 GMT</pubDate>
            <atom:updated>2020-07-04T19:34:56.287Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the best article I’ve found so far that does a really good job of explaining how to get an Oauth token using JWT. <a href="https://mannharleen.github.io/2020-03-03-salesforce-jwt/">https://mannharleen.github.io/2020-03-03-salesforce-jwt/</a></p><p>I wanted to take it one step further and providing a step-by-step so it can save time.</p><ol><li>Create a self-signed certificate. There are a few ways to do this but here’s how I generated one.</li></ol><pre>$ which openssl<br>/usr/bin/openssl</pre><pre>openssl genrsa -des3 -passout pass:x -out server.pass.key 2048</pre><pre>openssl rsa -passin pass:x -in server.pass.key -out server.key</pre><pre>rm server.pass.key</pre><pre>openssl req -new -key server.key -out server.csr</pre><pre>openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt</pre><p>2. Create a Connected App by going to App Manager &gt; New Connected App and fill in required fields. Make sure that Enable OAuth Settings is selected. Enter a value for Callback URL (it can be any valid url like one in the screenshot). Make sure that Check Use Digital Signatures and upload the server.crt file from step 1. Save the Connected App</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-bM9J2Ha5GUXvs59BtB0vQ.png" /></figure><p>3. Create a JWT using a JWT builder like this one <a href="https://jwt.io/">https://jwt.io/</a>. Refer to this article for more information on how to construct the JWT <a href="https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&amp;type=5">https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&amp;type=5</a>. Pay close attention to the Header and the Payload Data. You’ll also need the certificate and private key from Step 1 to construct the JWT token to get access to Salesforce.</p><p>Header:</p><pre>{<br>  &quot;alg&quot;: &quot;RS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;<br>}</pre><p>Payload Data: <strong>iss = connected app client id; aud = instance of the connected app; sub = valid user name in Salesforce; exp = Epoch Unix Time Stamp</strong></p><pre>{<br>  &quot;iss&quot;: &quot;3MVG9eYfd1zvW1E5VD4t_gFM2DJ0jXBAag5CUtQHGwPhwyvqnx2zrDuiaEYiYl3NtltuAU7g_fw7xf8e8rlgB&quot;,<br>  &quot;aud&quot;: &quot;<a href="https://test.salesforce.com/">https://test.salesforce.com</a>&quot;,<br>  &quot;sub&quot;: &quot;ValidSFUsername@mycompany.com&quot;,<br>  &quot;exp&quot;: 2222984108<br>}</pre><p>In the verify signature enter your public certificate and private key to generate your token.</p><p>4. Enable the Connected App for the profile by going to Profile &gt; Edit Profile of the user in Step 3 &gt; Assign Connected Apps</p><p>5. Create a Postman request like the one below and pass query parameters:</p><ul><li>grant_type: urn:ietf:params:oauth:grant-type:jwt-bearer</li><li>assertion: jwt token from Step 3</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeZuLTtlXiHrhm6eFe-l5w.png" /></figure><p>A successful setup should end up with the following:</p><pre>{</pre><pre>&quot;access_token&quot;: &quot;00D5w000006eqoW!AQcAQFhX2aTXlMNjCgnKVV4ooXADdEWWOpSUWy89GlbTRNrvDNjHQBb7KDnj3v8TpRp3iDcu95zWqqfL2QbShw4Hj9tGlOXl&quot;,</pre><pre>&quot;scope&quot;: &quot;visualforce wave_api custom_permissions web openid chatter_api id api eclair_api full&quot;,</pre><pre>&quot;instance_url&quot;: &quot;https://mycompany.my.salesforce.com&quot;,</pre><pre>&quot;id&quot;: &quot;https://login.salesforce.com/id/00D5w000006eqoWEAQ/0055w00000DDO76AAH&quot;,</pre><pre>&quot;token_type&quot;: &quot;Bearer&quot;</pre><pre>}</pre><p>6. Start using the access_token to make other requests to the Salesforce server.</p><p>Note: If you receive the following error, “We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: user hasn’t approved this consumer”, you’ll need to change the Connected App policy to “Admin approved users are pre-authorized”. To change the connected App Policy, go to Setup &gt; Manage Connected Apps &gt; Edit the connected App. Scroll down to Oauth Policies and change the Permitted Users Setting to Admin approved users are pre-authorized.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3600dd2a65de" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>