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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Authenticating with Business Central using an Azure Managed Identity

(1) ShareShare
ReportReport
Posted on by 8
Hi all,
 
I'm trying to authenticate an Azure Managed Identity with my organization's instance of Business Central. When I call the API using the token retrieved by the Managed Identity I receive the following payload:
 
{"type":"https://tools.ietf.org/html/rfc9110#section-15.5.2","title":"Unauthorized","status":401,"extensions":{"traceId":"00-0e3ad3db6e522d1656f3ede11a40f23f-d4ee9083ed25d510-01"}}
 
On the Business Central side, I've registered the Managed Identity as a Microsoft Entra Application per the documentation, however, the documentation doesn't mention managed identities. Managed identities don't use redirect URIs so I can't use the grant consent feature in Business Central. I am able to successfully call the API using my user credentials. I've tried applying several different permission scopes in Business Central, including the same permissions my user account has, and I still run into the same problem. I've used this same managed identity to authenticate with other apps, including a Dynamics 365 app powered by the Power Apps. 
 
Have any of you had a similar issue or know of any solutions? Thanks!
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,638 Super User 2025 Season 2 on at
  • BF-28011912-0 Profile Picture
    8 on at
    Thanks ZHU,

    However, I'm not trying to authenticate with Business Central using a Power Platform connector. Rather, I'm trying to connect via an HTTPS request in a python script. An example of the code I'm using is below. 
     
    from azure.identity import DefaultAzureCredential
    import requests
    from requests.auth import AuthBase

    class BearerTokenAuth(AuthBase):
        def __init__(self, token):
            self.token = token
        def __call__(self, r):
            r.headers["Authorization"] = f"Bearer {self.token}"
            return r

    # Set up Azure credentials
    credential = DefaultAzureCredential(
        managed_identity_client_id="<client_id>",
        workload_identity_tenant_id="<tenant_id>",
    )
    # Define the required scope for Business Central API
    bc_scope = "https://api.businesscentral.dynamics.com/.default"
     
    # Get the authentication token
    token = credential.get_token(bc_scope).token
     
    # Define the API endpoint
    endpoint = "https://api.businesscentral.dynamics.com/environments/v1.1"
     
    # Initialize authentication handler

    auth = BearerTokenAuth(token)
    # Make the API request

    response = requests.get(endpoint, auth=auth)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,577

#2
YUN ZHU Profile Picture

YUN ZHU 888 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 778 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans