Salesforce Access Token Generation

First, we will create a Salesforce App (Connected App) and obtain the OAuth 2 tokens from Salesforce REST API.

  1. Navigate in to the Salesforce developer edition and create a Salesforce account.

  2. Log in to Salesforce after verifying your account, with the newly created credentials. In the upper-right corner, select Setup.

  3. Navigate to Apps > App Manager and click on the New Connected App.

  4. On the New Connected App page, fill the required fields as listed below.

    • Fill in Connected App Name, API Name, and Contact Email under Basic Information.

    • Go to API (Enable OAuth Settings), and select Enable OAuth Settings.

    • In the Callback URL field, enter

    • In the Selected OAuth Scopes field, select the following:

      • Access and manage your data (API).
      • Perform requests on your behalf at any time (refresh_token, offline_access).
      • Provide access to your data via the Web (web), and then click Add.
  5. Click the Save button to save the new Connected App.

  6. Navigate to Connected Apps (Apps > App Manager) list, and click the App that you have just created, and then click on View.

  7. Go to API (Enable OAuth Settings), and note down the Consumer Key and Consumer Secret.

  8. On the page that opens, click the Edit button. Under OAuth policies, select All users may self-authorize in the Permitted Users list, and then click the Save button.

  9. Now we have to obtain the access token and refresh token as indicated below. Enter the following URL in your web browser. should be replaced with your instance name, in my example it is ap17.


    If this is a new browser, you will need to verify the account again with a code sent to the email, and login to the account. It will be redirected to a URL similar to the following.
  10. Note down the value of the code. In my case, it is:

  11. Now import the following in POSTMAN and obtain the tokens.

    curl --location --request POST "" \
    --header "Accept: */*" \
    --header "Accept-Encoding: gzip, deflate" \
    --header "Cache-Control: no-cache" \
    --header "Connection: keep-alive" \
    --header "Content-Length: 0" \
    --header "Host:" \
    --header "Postman-Token: 7d68f566-7907-443d-9cbc-f5a7205ff1af,7239d98b-8020-47cc-9922-595ef03c676c" \
    --header "User-Agent: PostmanRuntime/7.19.0" \
    --header "cache-control: no-cache"
  12. Once it is imported, you will have the following in POSTMAN. Replace the following fields with your values.

    • code
    • client_id
    • client_secret