menu

How to create salesforce connected apps to access the salesforce REST API calls

Yogesh

TreeImage
TreeImage

A connected app defines your application’s OAuth settings for the Salesforce organisation. This will use OAuth protocols to authenticate and provide tokens for use with Salesforce APIs. In addition to standard OAuth capabilities, connected apps allow Salesforce admins to set various security policies and have explicit control over who can use the corresponding apps.

Here are the steps to create connected apps in sales force

Make sure that your chrome browser has “Advanced Rest Client” and “ARC cookie exchange” extensions

Signup for salesforce developer account at this link. After signup is done a confirmation link will be sent to your e-mail.Approve the link sent to your e-mail and set password. Here password should not have any special symbols.

Now go to this link and complete the login process. After login is successfully done user specific dashboard comes up

Click on “New Connected App”. Under “Basic Information” fill in the mandatory fields marked with red

Under “API” select “Enable OAuth Settings”

Fill in “Callback URL” field

Under “Selected OAuth Scopes” select the below items one by one and click on add button

      “Full Access”

      “Provide access to your data via web”

      “Access and manage your data(api)”

Scroll down and click on “Save”.Next screen appears, now click on “continue”, then you will be taken to “Manage Connected Apps” Page

Here you can get ” Consumer Key” and “Consumer Secret”.Save both of them as you need them in the login API call

Now Click on Manage button, and then click on “Edit Policies”

In “IP Relaxation” dropdown, select “Relax IP Restrictions”

Leave the rest of the settings as they are

Now click on “Save”

This is the end of creation of connected app


Go to your dashboard of salesforce and click on top right icon ( profile icon ), then select settings

In the left side menu click on “Reset My security Token”. In the main page click on “Reset Security Token” button. Then security token will be sent to your email id. Save this as you need this in the login API call. This will be sent as access_token in login API call.

Find out API version

Click on setup icon on top right. In left navigation menu, in the search box, search for API. Click on API in the search results

Under “WSDL and Client Certificates”

      Under “Enterprise WSDL”

          click on “Generate Enterprise WSDL

Wait till the page loads and see the API version and note it down

Open the advanced REST client in Chrome, build the below API call and run ( Call type is POST ). Here in the below API request enter your account related values in each field. Here client_id is your consumer_key, client_secret is your consumer_secret and access_token is your security token. 

Call type POST 

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9d8..z.hDcPIf5K3O5ytCEaaObuEsmxWsAh.                              +++9Mz_jDw69X2WiWlf1PxReW6jDovwUVcPbEZvXmEqbpNCa&client_secret=3673268616169373668&username=<your_email>&password=<your password>&access_token=<your security_token>

The response would look something like this…

    {

        “access_token”: “00D7F000….”

        “instance_url”: “https://ap5.salesforce.com”,

        “id”: “https://login.salesforce.com/id/00D7F000005UlnWUAS/0057F000002qpoiQAA”,

        “token_type”: “Bearer”,

        “issued_at”: “1520263457284”,

        “signature”: “Qk4u4Kfuu2vLUB0WYBl05xDpyk+UItvuH57LNOq3JHU=”

    }

Now you can invoke your salesforce REST API calls by using the access_token i.e. by setting your raw header as

Authorization  Bearer <Your access_token which you got in login response>

Here instance_url you got in login response would be your base url to make REST API calls.

butterfly
Let'sTalk
butterfly
Thanks for the submission.