Step One: Update the Developer-Side Settings on the Connected App
From Setup, in the Quick Find box, enter App, and then select App Manager. On the dropdown menu next to your app, select Edit. You see a page that looks like this:
Now, Enable the checkbox “Enable Client Credentials Flow” as shown below and Click on Save.
Step Two: Update the Manage-Side Settings on the Connected App
From Setup, in the Quick Find box, enter App, and then select App Manager. On the dropdown menu next to your app, select Manage, and then click Edit Policies. You see a page that looks like this:
Click on Edit Policies and scroll down. In the Client Credentials Flow section, use the lookup field for Run As to look up the user in the org whose username you were using with the OAuth username-password flow
Step Three: Request token access and make api call
For example, where you are currently making a POST request similar to this one:
grant_type=password&
password=****&
client_id=************************************************************************&
client_secret=************************************************************************
(Change)Instead make a POST request like this one:
Host: test.salesforce.com
grant_type=client_credentials&
client_id=************************************************************************&
client_secret=************************************************************************
Once the token is received you can make another request to call the api. Pass the request body, along with that pass the token under Authorization (bearer).
Comments