Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Accessing Microsoft Dynamics online using Web API

Posted on by Microsoft Employee

Hi,

I am trying to access Dynamics CRM online using Web API, with authentication using the OAUTH 2.0 from Azure AD. Here is what I have done so far.

1. Registered my application in Azure AD in the App Registration.

2. Successfully authorize using https://login.microsoftonline/common end point. I am getting an Access Token and Refresh Token properly. I am also able to use the refresh token and get a new token. The resource I am passing to these is the Client ID of the application I registered.

3. I also configured Dynamics CRM Online (Microsoft.CRM) in the Required Permissions section of the application I registered.

Now, when I access Dynamics using the https://<mydomain>.crm.dynamics.com end point and access a resource (such as Account), I get a (401) Unauthorized error. This happens even with Postman application.

I have followed the steps in https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code

I also see another set of document - https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-service-to-service

Is this relevant here for my use?

Thanks!

Venkat Rangan

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Accessing Microsoft Dynamics online using Web API

    Sorry, I figured that the problem was the missing https:// before mydomain in scope.

    Now that I fixed it, I get a new error:

    Correlation ID: 24bcd582-4bf7-4b80-8734-114387021b4f

    Timestamp: 2017-10-06 20:48:15Z

    AADSTS70001: Application '<application-id>' is not supported for this API version.

    What is this referring to? Thanks!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Accessing Microsoft Dynamics online using Web API

    I also tried following the article: docs.microsoft.com/.../active-directory-v2-protocols-oauth-code

    The step "Request an authorization code" works fine for the Tutorial Sample App, but when I substitute my client_id and scope I get an an error:

    login.microsoftonline.com/.../authorize;response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F&response_mode=query&scope=mydomain.crm.dynamics.com&state=12345

    Error:

    AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope mydomain.crm.dynamics.com is not valid.

    How do I specify the "scope" parameter for Dynamics CRM?

    Thanks, again!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Accessing Microsoft Dynamics online using Web API

    The error I get is:

    {

       "error": "invalid_resource",

       "error_description": "AADSTS50001: The application named domain.crm.dynamics.com was not found in the tenant named domain.onmicrosoft.com.  This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant.  You might have sent your authentication request to the wrong tenant.\r\nTrace ID: fa87946e-c42c-4f1f-a595-dfd806403900\r\nCorrelation ID: d62d5c76-9c54-43d1-8a07-5b4d36ff7908\r\nTimestamp: 2017-10-06 17:38:35Z",

       "error_codes": [

           50001

       ],

       "timestamp": "2017-10-06 17:38:35Z",

       "trace_id": "fa87946e-c42c-4f1f-a595-dfd806403900",

       "correlation_id": "d62d5c76-9c54-43d1-8a07-5b4d36ff7908"

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans