<?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 Sathish Balaji on Medium]]></title>
        <description><![CDATA[Stories by Sathish Balaji on Medium]]></description>
        <link>https://medium.com/@bsathish-civ?source=rss-66b941ed0155------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*U5KZiKCmBYODDMdKlS0N0g.png</url>
            <title>Stories by Sathish Balaji on Medium</title>
            <link>https://medium.com/@bsathish-civ?source=rss-66b941ed0155------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:24:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bsathish-civ/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[Authenticate Salesforce from Golang using connected app JWT bearer token flow]]></title>
            <link>https://bsathish-civ.medium.com/authenticate-salesforce-from-golang-using-connected-app-jwt-bearer-token-flow-bc469b016940?source=rss-66b941ed0155------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc469b016940</guid>
            <category><![CDATA[jwt-auth]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[jwt-token]]></category>
            <category><![CDATA[salesforce]]></category>
            <dc:creator><![CDATA[Sathish Balaji]]></dc:creator>
            <pubDate>Sun, 19 Apr 2020 07:48:24 GMT</pubDate>
            <atom:updated>2020-06-24T09:52:00.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*V2DBS2JPS6OzzCvlvFS8XA.jpeg" /><figcaption>Access salesforce resources from golang app</figcaption></figure><p>Adoption of golang as backend programming language is increasing exponentially due to its Concurrency power, lightweightedness, scalability and much more.</p><p>And thus grows the need to integrate with salesforce CRM. There are a lot of ways to authenticate against salesforce from an external application using connected apps; though this article focuses only on JWT OAuth Bearer flow.</p><blockquote>JSON Web Tokens are an open, industry standard <a href="https://tools.ietf.org/html/rfc7519"><strong>RFC 7519</strong></a> method for representing claims securely between two parties.</blockquote><p>Unlike normal OAuth flows, this flow does not require interactive authentication and hence is useful to communicate between server to server.</p><h3><strong>Create a x509 self signed certificate</strong></h3><ol><li>Generate an RSA private key</li></ol><pre>openssl genrsa -des3 -passout pass:SomePassword -out server.pass.key 2048</pre><p>2. Generate a pass key with the server.pass.key from above step</p><pre>openssl rsa -passin pass:SomePassword -in server.pass.key -out server.key</pre><p>3. Generate the certificate</p><pre>openssl req -new -key server.key -out server.csr</pre><p>Enter all the required information which will be prompted from this step.</p><p>4. Generate the SSL certificate — final</p><pre>openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt</pre><ul><li>-days indicate the no of days until this certificate the valid.</li><li>x509 denotes that this certificate is self-signed and not from a CA</li></ul><p>server.key is maintained in Go app</p><p>server.crt is used as a digital signature in salesforce connected app</p><h3><strong>Create a connected app in salesforce</strong></h3><p>In your salesforce org,</p><ol><li>From Setup, enter App Manager in the Quick Find box, then select <strong>App Manager</strong>.</li><li>Click <strong>New Connected App</strong>.</li><li>Enter the connected app name and your email address:</li><li>Select <strong>Enable OAuth Settings</strong>.</li><li>Select <strong>Enable for Device Flow. </strong>Enabling this will auto populate the callback URL as device flows doesn’t require them.</li><li>Enable<strong> Use digital signatures. </strong>Upload the server.crt file for this digital signature.</li><li>Under <strong>Selected OAuth Scopes, </strong>select all scopes that apply**.</li><li>Click <strong>Save.</strong></li></ol><p>** Be cautious when selecting scopes as the external application can literally peek into everything depending on the scopes you choose</p><p>Copy the Consumer keywhich will be used by your Go app. Consumer keys are unique across salesforce ecosystem. Which means once you create a connected app in one org, it can be reused elsewhere instead of recreating it, which will create a different consumer key.</p><p>Click on <strong>Manage Policies </strong>button</p><p>There are 2 kinds of authorization for this connected app.</p><ol><li><em>Permitted users — </em><strong><em>All users may self-authorize </em></strong><em>— </em>When this option is set, any authentication with the connected app must be approved before by the user else salesforce throws an error while authenticating with message — ‘User hasn’t approved this consumer’.</li><li><em>Permitted users — </em><strong><em>Admin approved users are pre-authorized</em> </strong><em>— </em>When this option is set, you need to choose any profile or permission sets and the users who are assigned to it can authenticate with salesforce without any prior approval. Attention required — Consumer key and the server.key files are the only resources needed to break open into any org using this connected app, hence they are extremely confidential.</li></ol><p>Now that connected app is ready we can start developing Go code to access salesforce.</p><h3><strong>Create authentication requests in Go</strong></h3><p>Get the library — <strong><em>github.com/dgrijalva/jwt-go</em></strong> for JWT operations</p><pre>go get github.com/dgrijalva/jwt-go</pre><p>Rename the server.key to private_key.pem and place it in root directory of you golang app</p><p>Copy the below gist to your source code — preferably inside a folder called ‘authentication’. If you place this file in any folder/subdirectory, also move the private_key.pem along with it or use a relative path to the pem file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3efc83903b0afa3aac303a43adeb2eb9/href">https://medium.com/media/3efc83903b0afa3aac303a43adeb2eb9/href</a></iframe><p>Now import authentication package and start requesting access token like below</p><pre>package xxxxx</pre><pre>import ( <br>    sf &quot;&lt;directory&gt;/authentication&quot;<br>    &quot;net/http&quot;</pre><pre>)</pre><pre>func xxxx(){</pre><pre>    sfRequest := sf.AuthenticationRequest{<br>      &quot;https://test.salesforce.com&quot;,</pre><pre>      &quot;sbalaji@myorg.com&quot;,<br>    }</pre><pre>    authReponse, err := sf.Authenicate(sfRequest,   http.DefaultClient)</pre><pre>    accessToken := authReponse.GetToken()</pre><pre>}</pre><p>Now with the access token, you can access any resource from salesforce provided the scope permits to access that.</p><p>When you have tested this connected app and want to use in different organizations, do not create one in every org. Doing so will generate a new consumer key and secret everytime.</p><p><em>This connected app needs to be shipped so as to preserve the consumer key and consumer secret. Please comment below if you want a detailed article on how connected apps works including shipping it in a managed package.</em></p><p>More details on — <a href="https://www.rsforce.net/notes/categories/technical-notes">https://www.rsforce.net/notes/categories/technical-notes</a></p><blockquote>Happy exploring…</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc469b016940" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Host a Microservice in Heroku that mass deletes picklist options in salesforce, for free]]></title>
            <link>https://bsathish-civ.medium.com/host-a-microservice-in-heroku-that-mass-deletes-picklist-options-in-salesforce-for-free-1b3efe069751?source=rss-66b941ed0155------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b3efe069751</guid>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[picklist]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Sathish Balaji]]></dc:creator>
            <pubDate>Sun, 12 Apr 2020 13:56:30 GMT</pubDate>
            <atom:updated>2020-04-12T13:56:30.402Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Wipe out all the picklist options in a picklist field in salesforce" src="https://cdn-images-1.medium.com/max/700/1*K_mgNfcU7mxySaVhNpmLiQ.jpeg" /></figure><p>At times, there is a need to bulk delete all the picklist values from a particular or group of picklist fields in an object. It is a “is there any junior resource to do it for me” moment as the options will have to be deleted one by one, with no provision in salesforce to mass delete the picklists — as of this writing.</p><p>But this doesn’t stop us from creating our own service to achieve that. Let’s get started.</p><p><em>Abstract</em>:<em> We are going to create an app in NodeJs with express server framework and JSForce library which will delete the picklists in the org. This application will be hosted in heroku platform. From salesforce end, we create a LWC page which accepts object and picklists to wipe and a button to initiate the request to heroku.</em></p><p><strong>For someone who do not know what Heroku is?</strong></p><p>It is a cloud-based, platform as a service which lets users to build, run and manage applications hosted in them. And it is owned by salesforce.</p><p>The resources coming with free tier is more than sufficient for what we are going to build now — details here: <a href="https://www.heroku.com/pricing">https://www.heroku.com/pricing</a></p><p><strong>Creating the app</strong></p><p>Make sure you’ve installed the git cli in your system.</p><h4><em>Clone the app to your local from here:- </em><a href="https://gitlab.com/bsathish.civ/mass-delete-picklist-values.git"><em>https://gitlab.com/bsathish.civ/mass-delete-picklist-values.git</em></a></h4><p>In terminal, change directory to this cloned root.</p><p>I prefer using vscode since it has integrated terminal and a clean interface.</p><p><strong>Hosting in heroku</strong></p><p>Signup for heroku for free:- <a href="https://signup.heroku.com/">https://signup.heroku.com/</a></p><p><em>Install the heroku cli from here:-</em><a href="https://devcenter.heroku.com/articles/heroku-cli"><em>https://devcenter.heroku.com/articles/heroku-cli</em></a></p><p>Login to heroku in cli</p><pre>heroku login</pre><p>Now that you’re in the cloned app’s directory, issue the below command to create an app in heroku</p><pre>heroku create</pre><p>Once the app is created successfully, push all the change to heroku remote</p><pre>git push heroku master</pre><p>Heroku builds an application only from `master` branch. Hence if you’ve pushed it to a branch with different name, merge it to master.</p><p>Pushing to master automatically builds the source code and creates a slug out of it. A slug is an executable which is executed in heroku containers.</p><p>When the app is built and released, index.js file is executed and the server now listens on the port defined or on 5000. Now our app is ready to start accepting requests universally.</p><p>For reference here is the build log:-</p><pre>BLRWX10648:wipe-picklist-app sbalaji$ <strong>heroku create</strong><br>Creating app... done, ⬢ salty-inlet-29609<br><a href="https://salty-inlet-29609.herokuapp.com/">https://salty-inlet-29609.herokuapp.com/</a> | <a href="https://git.heroku.com/salty-inlet-29609.git">https://git.heroku.com/salty-inlet-29609.git</a><br>BLRWX10648:wipe-picklist-app sbalaji$ <strong>git push heroku master</strong><br>Enumerating objects: 27, done.<br>Counting objects: 100% (27/27), done.<br>Delta compression using up to 12 threads<br>Compressing objects: 100% (22/22), done.<br>Writing objects: 100% (27/27), 14.29 KiB | 2.86 MiB/s, done.<br>Total 27 (delta 7), reused 0 (delta 0)<br>remote: Compressing source files... done.<br>remote: Building source:<br>remote: <br>remote: -----&gt; Node.js app detected<br>remote:        <br>remote: -----&gt; Creating runtime environment<br>remote:        <br>remote:        NPM_CONFIG_LOGLEVEL=error<br>remote:        NODE_ENV=production<br>remote:        NODE_MODULES_CACHE=true<br>remote:        NODE_VERBOSE=false<br>remote:        <br>remote: -----&gt; Installing binaries<br>remote:        engines.node (package.json):  unspecified<br>remote:        engines.npm (package.json):   unspecified (use default)<br>remote:        <br>remote:        Resolving node version 12.x...<br>remote:        Downloading and installing node 12.16.1...<br>remote:        Using default npm version: 6.13.4<br>remote:        <br>remote: -----&gt; Installing dependencies<br>remote:        Installing node modules<br>remote:        added 125 packages in 2.781s<br>remote:        <br>remote: -----&gt; Build<br>remote:        <br>remote: -----&gt; Caching build<br>remote:        - node_modules<br>remote:        <br>remote: -----&gt; Pruning devDependencies<br>remote:        audited 242 packages in 1.329s<br>remote:        found 0 vulnerabilities<br>remote:        <br>remote:        <br>remote: -----&gt; Build succeeded!<br>remote: -----&gt; Discovering process types<br>remote:        Procfile declares types -&gt; web<br>remote: <br>remote: -----&gt; Compressing...<br>remote:        Done: 26.7M<br>remote: -----&gt; Launching...<br>remote:        Released v3<br>remote:        <a href="https://salty-inlet-29609.herokuapp.com/"><strong>https://salty-inlet-29609.herokuapp.com/</strong></a><strong> </strong>deployed to Heroku<br>remote: <br>remote: Verifying deploy... done.<br>To <a href="https://git.heroku.com/salty-inlet-29609.git">https://git.heroku.com/salty-inlet-29609.git</a><br> * [new branch]      master -&gt; master<br>BLRWX10648:wipe-picklist-app sbalaji$</pre><p>Now open the app at — copy the url you’ve got. For me its, (<a href="https://salty-inlet-29609.herokuapp.com/"><strong>https://salty-inlet-29609.herokuapp.com/</strong></a>). And check it out in the browser which should say that the service is running. <a href="https://salty-inlet-29609.herokuapp.com/"><strong>salty-inlet-29609</strong></a><strong> </strong>is the app name which heroku has auto created for you. This can be a custom name which can be provided while creating the app which must be globally unique and cannot exceed 30 characters.</p><p><strong>Initiating the request from salesforce</strong></p><p>I’ve created an unmanaged package with a lwc component, a tab and named credential to facilitate the connection to the new app.</p><h4><strong>Installation link:- https://test.salesforce.com/packaging/installPackage.apexp?p0=04tS0000000K8Km</strong></h4><p>Once this is installed, change the named credential (herokuUtilitiesApp)URL to point to the url of your app ex: <a href="https://salty-inlet-29609.herokuapp.com/"><strong>https://salty-inlet-29609.herokuapp.com/</strong></a><strong>.</strong></p><p>Go to the tab ‘Wipe Picklist Fields’ and — happy wiping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7zggupvGbLgywnb0lhKfGA.png" /><figcaption>mass delete picklist lwc page</figcaption></figure><p>Whoa! this is a lot of work to do, but still worth it and saves a lot of manual work.</p><p>Also developers, you can play around by adding more functionality to your heroku app and automate stuff.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b3efe069751" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>