Using JWT Flow to Authenticate Nodejs application with Salesforce

Video tutorial and Complete source code to use Salesforce JWT OAuth to authenticate Nodejs Application

JWT OAuth uses digital signature to authenticate external application with Salesforce. JWT can be used to request an OAuth access token from Salesforce when a client wants to use a previous authorization.

Complete Source code is available here.

How JWT OAuth works
  1. Developer creates a connected app and provides digital certificate in OAuth settings. You can refer this post to understand how openssl can be used to create digital certificate locally.
  2. We need to make sure this connected app is already pre – approved either by using WebServer, User Agent or any other flow. You can find this step in video recorded.
  3. We need to generate JWT token and sign it with certificate. This code snippet is available in this file in method getJWTSignedToken_nJWTLib(). I have used njwt module of Nodejs to create a JWT token. This is very useful website to validate and generate JWT token as per digital certificate.
  4. Next we need to send JWT request to token URL –  https://login.salesforce.com/services/oauth2/token
  5. If JWT request is valid then Salesforce returns access_token , which can be used in subsequent requests to perform allowed operations in Salesforce via Nodejs application.

Continue reading “Using JWT Flow to Authenticate Nodejs application with Salesforce”

Use Lightning Components on external websites – Lightning Out

How to use Lightning component in node.js (External websites) by using Lightning Out. It shows how to enable CORS and SSL in Node.js with Video and complete source code.

If you were the users of IGoogle, few years back, you would be excited to know that web development is progressing in that direction. Architect of web application development is getting shifted towards component based development by introducing concepts like Web Components and frameworks like polymer and Lightning Components. One of the possible use case of component driven development is ability to use whole component externally. In IGoogle, components were built by partners and then was exposed as widgets to be used on your custom Google home page. Salesforce product team, being visionary came up something like this by introducing Lightning Out. With the help of Lightning Out, we can surface our existing Lightning Component to external websites. Previously, we already discussed that how Lightning components can be used on Visualforce pages using Lightning Out.

Let’s see how we can do it. Continue reading “Use Lightning Components on external websites – Lightning Out”

Why to use Bower for your web developement

Author posted by Jitendra on Posted on under category Categories Node.js, Web Technology and tagged as Tags , , with 2 Comments on Why to use Bower for your web developement

What is Bower
It is client side package Manager and Great tool to manage all you web dependencies like JavaScript libraries and other assets.

Bower
Bower

What can be done from Bower
Web sites are made of lots of things — frameworks, libraries, assets, utilities, and rainbows. Bower manages all these things for you.

# registered package
$ bower install jquery

# GitHub shorthand – download repository SOQLBuilder from user Jitendra on Git
$ bower install JitendraZaa/SOQLBuilder

# Git endpoint
$ bower install git://github.com/user/package.git

# URL
$ bower install http://somewebsiteURL.com/script.js

Continue reading “Why to use Bower for your web developement”

How to use PostgreSQL in Nodejs

Author posted by Jitendra on Posted on under category Categories Node.js, Web Technology and tagged as Tags , , , , , with 8 Comments on How to use PostgreSQL in Nodejs

I have written many articles on Node.js and AngularJs. In this article, I will demonstrate how to use PostgreSQL with Node.js and deploy on Heroku. I think you already smelled that this is one of starting article which will finally merged with Salesforce to create some cool application.

Assuming you already have some background knowledge on Node.js and Heroku, If not please visit previous articles of this blog or my Slideshare account. Using Angularjs is totally optional and you can use library like JQuery or plain JavaScript.

To connect PostgreSQL, we need “pg” module.

PostgreSQL in Node.js
PostgreSQL in Node.js

Continue reading “How to use PostgreSQL in Nodejs”

Dreamforce 2014 Session – create web based IDE for Salesforce

In Dreamforce 2014, I got chance to present demo of creating online IDE for Salesforce using Tooling API. I used Node.js as a language to communicate with Salesforce API on Heroku Platform.

Demo

  1. Simple Editor

Complete source code (Github)

  1. Simple Editor
  2. Editor with Ace framework

Dont forget to share your feedback.

Below is the presentation slide I used

Creating Salesforce Query Builder in Node.js and AngularJs using Salesforce REST API and OAuth2 with Heroku Button

In this post, we will be creating a Salesforce Query (SOQL) Builder. It uses Google’s Angularjs MVC Javascript library and REST API provided by Salesforce. For Authentication, it uses OAuth2.

Node.js is used as a primary language and hosted on Heroku. If you want to directly deploy to your Heroku Account, You can use Heroku Button on this Git Repository.

We have many tools available online for Query builder, However none of them were satisfying me so though to create my own tool.

This Node.js application is used for building SOQL with following features :

  • Toggle between API name and Label Name
  • Search Objects or Fileds needs to build SOQL (In my case, it was primitive. I had more than 70 Objects and many of those objects has 300+ fields)
  • Checkboxes to select fields (No need to hold control button to select multiple fields)
  • Automatic Query Builder at Right side of page
  • Shows API count used by application
  • Search returned records
  • Sorting on Table Headers
  • Pagination

Note : You will need to create “Connected App” in Salesforce to allow OAuth as explained in this post.

Live Demo of application

Continue reading “Creating Salesforce Query Builder in Node.js and AngularJs using Salesforce REST API and OAuth2 with Heroku Button”

Create Node.js Application using Eclipse and deploy to Heroku – Video Tutorial

In Below video, I have explained how to create basic Node.js application in Eclipse with help of Egit and Heroku plugin and deploy to Heroku.

Please read below two articles, to get familiar of Plugins and how to setup :

  1. Salesforce + Git + Eclipse + EGIT = Better and Distributed Source Control
  2. Creating First Application in Heroku using Eclipse

Continue reading “Create Node.js Application using Eclipse and deploy to Heroku – Video Tutorial”