I have an Azure AD App Registration where I've exposed an API scope called AppUser.
This scope is being used for authentication in my Web API project, and everything works fine when the API is called from our frontend application (which uses delegated user authentication).
Now I have a background service (Azure WebJob) that needs to call the same protected API.
Since there's no user context, I tried using the client credentials flow (application permissions).
However, my API requests from the web job are failing with an authentication/authorization error.
What I've tried:
Used client credentials flow with
client_id,client_secret, andscope = api://{api-client-id}/.defaultVerified API permissions in Azure portal
But the API still returns HTTP 401 Unauthorized.