Hello,
I am working on developing an integration with Dynamics CRM and using OAuth for authentication. I have created a OAuth App in Azure and with that I am able to generate "access_token" which is required to access the APIs. I have developed and tested application with this and everything is working fine.
Now I am planning to move my app to beta in which other users could try my app out. I have hardcoded "client_id", "client_secret" and "redirect_URI" in my app. When people are trying to authenticate, the authorize URL getting formed something like this -
Here MY_CUSTOMERS_CRM_INSTANCE_URL is something like https://XXXX.crm8.dynamics.com
with the above URL I am getting the code. I am using that code to do a POST call on https://login.windows.net/common/oauth2/token to generate the access token. The tokens calls is also working fine and I am getting the "access_toke", "refresh_token", "resource" in response. here the resource returned in response is MY_CUSTOMERS_INSTANCE_URI which they have entered while initiating authentication.
The problem I am facing is when I am trying to use this API to fetch the "Contacts" or "Accounts" from Customer's CRM instance. My API call is something like this -
https://XXXX.crm8.dynamics.com/api/data/v8.2/accounts/
and in headers I am passing
Authorization: Bearer <ACCESS_TOKEN_RECIEVED_IN_TOKENS_CALL_RESPONSE>
HTTP Error 401 - Unauthorized: Access is denied
All the calls made above are from a NODE_APPLICATION developed by me.
I have earlier worked on OAuth for other applications(e.g. Box.com) and there using the similar flow, I was able to make the API calls. Please suggest if anything I am missing.
*This post is locked for comments