How to create Refresh token in Salesforce ?

Step 1: Create a url as like below URL using client id and call back URl (get from connected app)

 
https://test.salesforce.com/services/oauth2/authorize?response_type=code&client_id=MXHjvPJXkGeXDF5Cwc9mSnTICpZWBHmETUeqBmWZ71Y3XVu&redirect_uri=https://test.salesforce.com/services/oauth2/token 

Step 2: Paste this URL in web browser and hit enter, then we will get new URL similar to below in the browser (Don't worry about the response in the window, just copy the URL and see)

 
https://test.salesforce.com/services/oauth2/token?code=aPrxH_Ak6v5NNlvlpsfetrgrtrtreRoCFlKIl1YiHlW9krfGOZ7KNsuQ%3D%3D

Step 3:Create one more URL by using Client id, Client secret and Code (generated in step 2)

 

https://test.salesforce.com/services/oauth2/token?grant_type=authorization_code&client_id=3MVG9d3kx8wbPieFuFVCMsFlUx8b4Yewrfdfr45ft4t9ZR9UbV_qSOTjQlPoO&client_secret=571ADC6712323242444242424224242&redirect_uri=https://test.salesforce.com/services/oauth2/token&code=aPrxH_Ak6v5NNlvlpsfetrgrtrtreRoCFlKIl1YiHlW9krfGOZ7KNsuQ%3D%3D 

Step 4: Copy and paste the above URL in browser and hit the enter, then you will get the Refresh Token

 


<OAuth>
<access_token>
00D4F0000000vVK!JHghjdghsgjhJhd.EzWZx7f3B.ReG0KubznItjXeZbfgONPSgmd_4LSuw_CUs.Zm1PipsjKkwsfIu
</access_token>
<refresh_token>
5Aep861fToiFLirtzuk14Z_5BaFKQzaGBQdjhfoYP6w_5h_7fhvYhtrbfrBGfhtHHRfhh
</refresh_token>
<signature>cVUV6NI79EQX79AhulIrtgA6XcVmun4Emi+P0=</signature>
<scope>refresh_token full</scope>
<id_token>...</id_token>
<instance_url>https://test.salesforce.com</instance_url>
<id>...</id>
<token_type>Bearer</token_type>
<issued_at>1579076257539</issued_at>
</OAuth>


now, we can generate new access token every time by using client_id, client_secret, Grant Type=refresh_token, refresh_token and redirect_uri


Comments