In this blog, I am going to explain how to setup and test OAuth username and password flow also called as Resource Owner Password Credentials Flow.With this type of authorization, the credentials (and thus the password) are sent to the client and then to the authorization server along with the client and client secret. In this flow, the user’s credentials are used by the application to request an access token which you case use to access the data on behalf of the user.
If you would like to access another salesforce instance data by using rest API
Resource Owner has a trust relationship with the client like if you are making calls from internal or secured on-premise application.
Create a Connected App
Navigate to App Setup > Create > Apps > Connected Apps > New
Enter Connected App Name, API Name, Contact Email
In the API (Enable OAuth Settings) Section click the Enable OAuth Settings checkbox.
id—Identity URL that can be used to both identify the user and query for more information about the user.
signature—Base64-encoded HMAC-SHA256 signature signed with the consumer’s private key containing the concatenated ID and issued_at. Use to verify that the identity URL hasn’t changed since the server sent it.
issued_at—When the signature was created.
Let’s test it
now the below code is used to send the OAuth details to salesforce endpoint URL which is going to return access token. you can use access token for subsequence calls.