SlideShare a Scribd company logo
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
Salesforce
Developer Group
Bengaluru, India
@ SFDGBLR #SFDGBLR
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
OAuth Authorization
flows in Salesforce
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
TABLE OF
CONTENTS
Connected App
Creating Connected App and
Managing Connected App Usage
OAuth Web Server
Flow
Demo through Postman HTTP
Client
01
03
02
04
05
OAuth JWT Bearer
Token Flow
What is JWT? Walkthrough with
Postman HTTP Client
OAuth JWT Bearer
Token Flow in Apex
Apex Code Walkthrough to
connect one salesforce org to
another using named credentials
RESOURCES
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
Connected App
01
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
Connected App
A connected app is a framework that enables an external application to integrate with Salesforce using
APIs and standard protocols, such as SAML, OAuth, and OpenID Connect. Connected apps use these
protocols to authenticate, authorize, and provide single sign-on (SSO) for external apps.
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
1. Creating Connected App
2. Managing Connected App Usage and Policies.
DEMO
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
OAuth Web server
flow
02
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
OAuth Web server
flow
1. The external web service—via the connected app—posts an authorization
code request using the authorization code grant type to the Salesforce
authorization endpoint.
2. With an authorization code, the connected app can prove that it’s been
authorized as a safe visitor to the site and that it has permission to request
an access token.
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
1. OAuth Web server flow walkthrough with Postman
HTTP Client.
DEMO
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
1. https://login.salesforce.com/services/oauth2/autho
rize?client_id=xxx&redirect_uri=https://login.sale
sforce.com/oauth2/callback&response_type=code
2. Endpoint for access token:
https://login.salesforce.com/services/oauth2/token
POST /services/oauth2/token,Content-type:
application/x-www-form-
urlencoded,grant_type=authorization_code&code=from
step1(url
decoded)&client_id=xxx&client_secret=xxx&redirect_
uri=https://login.salesforce.com/oauth2/callback
Steps Involved in Web Server Flow
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
OAuth JWT Bearer
Token flow
03
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
OAuth JWT Bearer
Token flow
1. This is used for server to server integration scenarios.
2. This flow uses a certificate to sign the JWT request and doesn’t require
explicit user interaction. However, this flow does require prior approval
of the client app. Please note this flows never issues a refresh token.
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
JWT Structure
Header -{"alg":"RS256"}
Payload (This contains claims information which
is an object containing information about user
and additional data.Claims are set using
parameters-"Iss,aud,sub,exp")
Signature
<headerbase64encodedurl>.<claimsbase64encodedclai
ms>.<signature(uses algorithm like RS 256)>
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
1. OAuth JWT Bearer Token flow walkthrough with
Postman HTTP Client.
DEMO
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
POST /services/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type= urn:ietf:params:oauth:grant-type:jwt-
bearer&assertion=JWT token generated in JWT.io Website
Steps to be followed in Postman
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
OAuth JWT Bearer
Token flow Usage in
Apex
04
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
1. OAuth JWT Bearer Token flow (Apex code
walkthrough to integrate one salesforce org to
another using named credentials)
DEMO
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
Auth.JWT jwt = new Auth.JWT();
jwt.setSub('debarunsengupta2512@live.com');
jwt.setAud('https://login.salesforce.com'); jwt.setIss('connected app client
id');Auth.JWS jws = new Auth.JWS(jwt,’Certificate keystore name’);String token =
jws.getCompactSerialization();String tokenEndpoint =
'https://login.salesforce.com/services/oauth2/token';//POST the JWT bearer token
Auth.JWTBearerTokenExchange bearer = new Auth.JWTBearerTokenExchange(tokenEndpoint,
jws);
//Get the access token
String accessToken = bearer.getAccessToken();
system.debug('Access Token-->'+accessToken);
Apex Code without Named
Credentials
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
String service_limits='/services/data/v48.0/sobjects/Account/listviews/';
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:JWT_Demo'+service_limits);
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
System.debug(res.getstatuscode());
Apex Code with Named Credentials
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
Resources
05
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
1. https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&type=5
2. https://jwt.io/
3. https://developer.salesforce.com/docs/atlas.en-
us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_key_and_cert.htm
4. https://www.base64encode.org/
5. https://www.freeformatter.com/json-formatter.html#ad-output
6. https://www.unixtimestamp.com/
Some Useful commands to convert .crt to keystore to store in SFDC
openssl pkcs12 -export -in server.crt -inkey server.pem -out testkeystore.p12
keytool -importkeystore -srckeystore testkeystore.p12 -srcstoretype pkcs12 -destkeystore servercert.jks -deststoretype JKS
keytool -keystore /<Path>/servercert.jks -changealias -alias 1 -destalias salesforcetest
Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR
CREDITS: This presentation template was created by Slidesgo, including
icons by Flaticon, and infographics & images by Freepik.
Please keep this slide for attribution.

More Related Content

PPTX
Building strong foundations apex enterprise patterns
PPTX
Salesforce Integration Pattern Overview
PDF
Introduction to the Salesforce Security Model
PPTX
Admin Webinar—An Admin's Guide to Profiles & Permissions
PPTX
Fusion Cash Management - Bank Account Reconciliation.pptx
PPTX
Oracle ERP and General Ledger Configuration
PPTX
Webcast: BUDGETING - R12.1.3 ORACLE GENERAL LEDGER
PDF
“How to Secure Your Applications With a Keycloak?
Building strong foundations apex enterprise patterns
Salesforce Integration Pattern Overview
Introduction to the Salesforce Security Model
Admin Webinar—An Admin's Guide to Profiles & Permissions
Fusion Cash Management - Bank Account Reconciliation.pptx
Oracle ERP and General Ledger Configuration
Webcast: BUDGETING - R12.1.3 ORACLE GENERAL LEDGER
“How to Secure Your Applications With a Keycloak?

What's hot (20)

PPTX
Apex collection patterns
PDF
Architecting Multi-Org Solutions
PDF
Apache Jackrabbit Oak - Scale your content repository to the cloud
PDF
Oracle Compensation Management
PDF
Decluttering your Salesfroce org
DOCX
Functional Design Document - Payroll V.2.2.docx
PDF
Apex Enterprise Patterns: Building Strong Foundations
PDF
Development Best Practices
PDF
دورة حياة المنتج
PPTX
Salesforce APIs
PDF
Apex Design Patterns
PPTX
Multiorg Collaboration Using Salesforce S2S
PPTX
Salesforce Security Best Practices for Every Admin
PPT
Salesforce REST API
PDF
BRD- MAINTENANCE
PDF
Apache Jackrabbit Oak on MongoDB
PDF
Deep Dive into OAuth for Connected Apps
PDF
Sec007 条件付きアクセス
PPTX
Salesforce Integration with MuleSoft | MuleSoft Mysore Meetup #12
Apex collection patterns
Architecting Multi-Org Solutions
Apache Jackrabbit Oak - Scale your content repository to the cloud
Oracle Compensation Management
Decluttering your Salesfroce org
Functional Design Document - Payroll V.2.2.docx
Apex Enterprise Patterns: Building Strong Foundations
Development Best Practices
دورة حياة المنتج
Salesforce APIs
Apex Design Patterns
Multiorg Collaboration Using Salesforce S2S
Salesforce Security Best Practices for Every Admin
Salesforce REST API
BRD- MAINTENANCE
Apache Jackrabbit Oak on MongoDB
Deep Dive into OAuth for Connected Apps
Sec007 条件付きアクセス
Salesforce Integration with MuleSoft | MuleSoft Mysore Meetup #12
Ad

Similar to OAuth Authorization flows in salesforce (20)

PPTX
CRM Science - Dreamforce '14: Using the Google SOAP API
PDF
Authentication with OAuth and Connected Apps
PPTX
OAuth with Salesforce - Demystified
PDF
Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore
PDF
Introduction to the Salesforce Mobile SDK for Android
PDF
Introduction to the Salesforce.com Mobile SDK for iOS
PPTX
How to Use Stormpath in angular js
PDF
Introduction to Developing Android Apps With the Salesforce Mobile SDK
PDF
SalesForce WebServices part 2
PDF
SharePoint Fest Chicago 2015 - Anatomy of configuring provider hosted add-in...
PDF
JHipster and Okta - JHipster Virtual Meetup December 2020
PDF
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
DOC
SankethNM[2_10]
PDF
How to Implement Token Authentication Using the Django REST Framework
PPTX
OpenID Connect and Single Sign-On for Beginners
PDF
Painless Mobile App Development Webinar
PDF
RESTful Day 5
PPTX
Microsoft Graph API Delegated Permissions
PPTX
Connect Your Clouds with Force.com
PDF
Web Application Penetration Testing Checklist
CRM Science - Dreamforce '14: Using the Google SOAP API
Authentication with OAuth and Connected Apps
OAuth with Salesforce - Demystified
Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore
Introduction to the Salesforce Mobile SDK for Android
Introduction to the Salesforce.com Mobile SDK for iOS
How to Use Stormpath in angular js
Introduction to Developing Android Apps With the Salesforce Mobile SDK
SalesForce WebServices part 2
SharePoint Fest Chicago 2015 - Anatomy of configuring provider hosted add-in...
JHipster and Okta - JHipster Virtual Meetup December 2020
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
SankethNM[2_10]
How to Implement Token Authentication Using the Django REST Framework
OpenID Connect and Single Sign-On for Beginners
Painless Mobile App Development Webinar
RESTful Day 5
Microsoft Graph API Delegated Permissions
Connect Your Clouds with Force.com
Web Application Penetration Testing Checklist
Ad

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PPTX
L1 - Introduction to python Backend.pptx
PDF
Nekopoi APK 2025 free lastest update
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
medical staffing services at VALiNTRY
PPTX
ai tools demonstartion for schools and inter college
PDF
AI in Product Development-omnex systems
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
top salesforce developer skills in 2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Introduction to Artificial Intelligence
PPTX
Essential Infomation Tech presentation.pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How Creative Agencies Leverage Project Management Software.pdf
System and Network Administration Chapter 2
L1 - Introduction to python Backend.pptx
Nekopoi APK 2025 free lastest update
wealthsignaloriginal-com-DS-text-... (1).pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Odoo POS Development Services by CandidRoot Solutions
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
medical staffing services at VALiNTRY
ai tools demonstartion for schools and inter college
AI in Product Development-omnex systems
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
top salesforce developer skills in 2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Introduction to Artificial Intelligence
Essential Infomation Tech presentation.pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
How to Choose the Right IT Partner for Your Business in Malaysia
Understanding Forklifts - TECH EHS Solution
How Creative Agencies Leverage Project Management Software.pdf

OAuth Authorization flows in salesforce

  • 1. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR Salesforce Developer Group Bengaluru, India @ SFDGBLR #SFDGBLR
  • 2. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR OAuth Authorization flows in Salesforce
  • 3. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR TABLE OF CONTENTS Connected App Creating Connected App and Managing Connected App Usage OAuth Web Server Flow Demo through Postman HTTP Client 01 03 02 04 05 OAuth JWT Bearer Token Flow What is JWT? Walkthrough with Postman HTTP Client OAuth JWT Bearer Token Flow in Apex Apex Code Walkthrough to connect one salesforce org to another using named credentials RESOURCES
  • 4. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR Connected App 01
  • 5. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR Connected App A connected app is a framework that enables an external application to integrate with Salesforce using APIs and standard protocols, such as SAML, OAuth, and OpenID Connect. Connected apps use these protocols to authenticate, authorize, and provide single sign-on (SSO) for external apps.
  • 6. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR 1. Creating Connected App 2. Managing Connected App Usage and Policies. DEMO
  • 7. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR OAuth Web server flow 02
  • 8. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR OAuth Web server flow 1. The external web service—via the connected app—posts an authorization code request using the authorization code grant type to the Salesforce authorization endpoint. 2. With an authorization code, the connected app can prove that it’s been authorized as a safe visitor to the site and that it has permission to request an access token.
  • 9. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR 1. OAuth Web server flow walkthrough with Postman HTTP Client. DEMO
  • 10. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR 1. https://login.salesforce.com/services/oauth2/autho rize?client_id=xxx&redirect_uri=https://login.sale sforce.com/oauth2/callback&response_type=code 2. Endpoint for access token: https://login.salesforce.com/services/oauth2/token POST /services/oauth2/token,Content-type: application/x-www-form- urlencoded,grant_type=authorization_code&code=from step1(url decoded)&client_id=xxx&client_secret=xxx&redirect_ uri=https://login.salesforce.com/oauth2/callback Steps Involved in Web Server Flow
  • 11. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR OAuth JWT Bearer Token flow 03
  • 12. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR OAuth JWT Bearer Token flow 1. This is used for server to server integration scenarios. 2. This flow uses a certificate to sign the JWT request and doesn’t require explicit user interaction. However, this flow does require prior approval of the client app. Please note this flows never issues a refresh token.
  • 13. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR JWT Structure Header -{"alg":"RS256"} Payload (This contains claims information which is an object containing information about user and additional data.Claims are set using parameters-"Iss,aud,sub,exp") Signature <headerbase64encodedurl>.<claimsbase64encodedclai ms>.<signature(uses algorithm like RS 256)>
  • 14. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR 1. OAuth JWT Bearer Token flow walkthrough with Postman HTTP Client. DEMO
  • 15. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR POST /services/oauth2/token HTTP/1.1 Content-Type: application/x-www-form-urlencoded grant_type= urn:ietf:params:oauth:grant-type:jwt- bearer&assertion=JWT token generated in JWT.io Website Steps to be followed in Postman
  • 16. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR OAuth JWT Bearer Token flow Usage in Apex 04
  • 17. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR 1. OAuth JWT Bearer Token flow (Apex code walkthrough to integrate one salesforce org to another using named credentials) DEMO
  • 18. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR Auth.JWT jwt = new Auth.JWT(); jwt.setSub('debarunsengupta2512@live.com'); jwt.setAud('https://login.salesforce.com'); jwt.setIss('connected app client id');Auth.JWS jws = new Auth.JWS(jwt,’Certificate keystore name’);String token = jws.getCompactSerialization();String tokenEndpoint = 'https://login.salesforce.com/services/oauth2/token';//POST the JWT bearer token Auth.JWTBearerTokenExchange bearer = new Auth.JWTBearerTokenExchange(tokenEndpoint, jws); //Get the access token String accessToken = bearer.getAccessToken(); system.debug('Access Token-->'+accessToken); Apex Code without Named Credentials
  • 19. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR String service_limits='/services/data/v48.0/sobjects/Account/listviews/'; HttpRequest req = new HttpRequest(); req.setEndpoint('callout:JWT_Demo'+service_limits); req.setMethod('GET'); Http http = new Http(); HTTPResponse res = http.send(req); System.debug(res.getBody()); System.debug(res.getstatuscode()); Apex Code with Named Credentials
  • 20. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR Resources 05
  • 21. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR 1. https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&type=5 2. https://jwt.io/ 3. https://developer.salesforce.com/docs/atlas.en- us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_key_and_cert.htm 4. https://www.base64encode.org/ 5. https://www.freeformatter.com/json-formatter.html#ad-output 6. https://www.unixtimestamp.com/ Some Useful commands to convert .crt to keystore to store in SFDC openssl pkcs12 -export -in server.crt -inkey server.pem -out testkeystore.p12 keytool -importkeystore -srckeystore testkeystore.p12 -srcstoretype pkcs12 -destkeystore servercert.jks -deststoretype JKS keytool -keystore /<Path>/servercert.jks -changealias -alias 1 -destalias salesforcetest
  • 22. Salesforce Developer Group Bengaluru, India - @SFDGBLR #SFDGBLR CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, and infographics & images by Freepik. Please keep this slide for attribution.