Tech Force

Technical Blog & Projects about Salesforce

Follow publication

Salesforce API — JWT Authentication

Salesforce JWT Authentication with Python and Postman example

Techletters
Tech Force
Published in
5 min readJul 10, 2022
Salesforce API — JWT Authentication

Using JWT to connect to the Salesforce API seems tricky and the official Salesforce documentation is not very beginner-friendly. Don’t worry — it's not that hard. I will show you all the details below. This story contains the following steps.

  • Basic introduction
  • How to create a certificate?
  • Creation of a Connected App in Salesforce
  • Construct the JWT
  • Working example with Postman
  • Working implementation with Python

Basic introduction

JWT — short for JSON Web Token — is an Internet Standard and often used for authentication. It’s basically a string that holds information in a JSON-based structure, divided into different segments: header, payload & signature.

The Header contains information about the cryptographic algorithm used to generate the signature.

The Payload is a set of claims that contain the details. The JWT specification defines seven standard claims that are commonly included in tokens. Additionally, custom claims can be used, depending on the purpose of the token.

The Signature validates the token. The signature is calculated by encoding header and payload, and concatenating the two together with a period separator. That string is then run through the cryptographic algorithm specified in the header.

Salesforce allows using JWT for authentication to their APIs as well. Let’s see how.

How to create a Certificate?

Salesforce only accepts RSA SHA256-signed JWTs, so you need an X509 Certificate and its private key. Sounds complex, but it’s not. Just follow the following steps.

  • Download & Install OpenSSL

OpenSSL is a full-featured toolkit for cryptography and secure communication. You can download & use it for free. As the installation on windows can be tricky, you can also install git — which contains OpenSSL under the hood.

  • Create X509 Certificate & Key

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Tech Force
Tech Force

Published in Tech Force

Technical Blog & Projects about Salesforce

Techletters
Techletters

Written by Techletters

#ai #datascience #salesforce #crypto #kafka #python — Follow me: https://techletters.medium.com/membership

Responses (3)

Write a response