How To Do OAuth Access Setting Through Connected App

Steps For Making OAuth Access Setting Through Connected App

1 Add the PostMan Extension to the Browser.
2 Login into ur Oauth Account.
3 Then We have create a Connected App in the Organisation.
4 for that Connected App we will get
● Consumer Key
● Consumer Secret
5 Now we have to set the Callback URL that we will get from Postman (GET NEW ACCESS TOKEN) by callback URL
6 Now in the Postman go to the Authorization and form Type select OAuth 2.0
7 From Existing Token select GET NEW ACCESS TOKEN
8 Now Set
● Auth URl as (For Production).
● Access Token URL (For Production).
● Client ID will be the Consumer Key of the Connected App.
● Client Secret will be the Consumer Secret of the Connected App.
● Grant Type select Authorization Code.
● Check request access token locally.
● Click Request Token
9 We will get the Token
10 From the token Name use the Instance Url. The URL be like
Add services/apexrest/jss3 (Final URL)

URL For The Public Access

Step to call the data in Postman from different org

1 we have to make a post request from Postman on the URL like$1995VcXJ1N6faoQwWWehhGMgRMGQ2&grant_type=password

Url Contain
Username of that user from which ur bring the data.
Password with the Secret Token.
Client_secret of that user from which ur bring the data.
Client_id of that user from which ur bring the data.
Access Token URL of that user from which ur bring the data.

2 This will give us the data we need to access.
3 Now we have to hit it again with the get method of the different URL which is like

Here is the authentication class code :
Authentication Class

public class Aouth {
private static String clientId = '3MVG9YDQS5WtC11rq3DE08phrqNyW1WlIbzvwb7iBmB7RK4MYHagRiDY5BLWYJQ8vyHAP..TX25FtbXz7y0wX';
private static String clientSecret = '1816243741140611103';
private static String username = '';
private static String password = 'Manku@2000x9mtmHfTqEDLSjtoXhJHff8fl';
public class deserializeResponse
public String id;
public String access_token;
public static void ReturnAccessToken ()
String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
Http h = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res = h.send(req);
deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);


if(resp1.access_token != null){
String endPoint = '';

Http h2 = new Http();
HttpRequest req1 = new HttpRequest();
req1.setHeader('Authorization','Bearer ' + resp1.access_token);
// req1.setHeader('accept','application/json');

req1.setBody('{"Id":"0016F00002D9TnP","Name":"Kapil Dev","Phone":"9897989712","Description":"He is a good Cricketer"}');
HttpResponse res1 = h2.send(req1);


Hits: 199

Share Post

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *