web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting "HTTP Error 401 - Unauthorized: Access is denied" while trying to access Dynamics 365 Online resource using Client Credentials

(0) ShareShare
ReportReport
Posted on by

I am trying to get Dynamics 365 online data using access token received on successful authentication by using client credentials for an Web app / API application . However getting 401 always.

Here is what I am doing:

  1. Authentication

    Request URL:
    POST https://login.microsoftonline.com/tenantId/oauth2/token

    Request Headers:
    Content-Type: application/x-www-form-urlencoded
    Accept: application/json

    Request Body:
    client_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
    resource: domain.crm.dynamics.com
    grant_type: client_credentials
    client_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx=

    Response Status: 200 OK
    Response Body (Sample):
    {
    "token_type": "Bearer",
    "expires_in": "3599",
    "ext_expires_in": "0",
    "expires_on": "1524644921",
    "not_before": "1524641021",
    "resource": "domain.crm.dynamics.com",
    "access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }

  2. Request a Dynamics resource using the received access_token

    Request URL:
    GET https://domain.crm.dynamics.com/api/data/v8.2/accounts?$select=name

    Request Headers:
    Accept: application/json
    OData-MaxVersion: 4.0
    OData-Version: 4.0
    Authorization: Bearer {{access_token}}

    Response Status: 401 Unauthorized
    Response Body: HTTP Error 401 - Unauthorized: Access is denied
    Response Headers:
    WWW-Authenticate: Bearer authorization_uri=https://login.windows.net/tenantId/oauth2/authorize, resource_id=domain.crm.dynamics.com

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ryan Spain Profile Picture
    52 on at

    Hi Suvasish,

    Three things worth checking here given the error response:

     

    1. Required Permissions

    Add permissions to the App Registration to access Dynamics CRM Online(see item 1 in screenshot below). Then use the "Grant permissions" button.

    2. Application User
    Ensure that an Application User in setup in Dynamics using the Client ID(see item 2 in screenshot below) from the App Registration in Azure.

    3. Security Role
    Ensure that a custom security role is assigned to the above Application User. You can just do a copy of System Administrator or similar.

    3666.Screenshot_5F00_45.png

    Hope this helps,

    Ryan

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans