How to Authenticate from External Python Script with Azure AD (OAuth Flow for App Service)

Kim JaeYoung (VM/ETO3) 0 Reputation points
2025-04-14T04:31:55.5966667+00:00

Hello, I am trying to access an internal API that is protected by Azure App Service Authentication . I understand that it uses Microsoft OAuth 2.0 flow and issues an "x-ms-token" when accessed through the browser. However, I would like to access this API using an external Python script. Since public client flows are not allowed in our tenant ("Public Client Flows = No"), flows like device code or ROPC are not available. I tried using the client credentials flow, but the x-ms-token is not included in the response. Could you please advise how to correctly authenticate from an external (non-browser) Python application when the API is protected by Azure App Service OAuth? Is there a recommended OAuth flow or configuration for this use case?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,673 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.