How can I use an apikey or bearer token with App service authentication/"Easy Auth"

DaveVs 26 Reputation points
2021-07-23T03:27:02.383+00:00

Hi
Setup as follows:

  • Azure app service dotnet core web application (Razor pages)
  • This app also includes an small API controller (within the same application).
  • Want to migrate to use app services Authentication (easy auth) with AD instead of handling auth within the code.

I have setup easy auth to Active Directory for users to login and this works well.

For the API in my app, I need to access it using an api key or bearer token from an old application client.

Is there any way of creating a static key or token that I can use for this? For various reasons, the old client cannot do redirects for tokens etc... I just want to be able to put a key in the HTTP Header of the post request on this client to authorize it..

Is this possible without separating my API out into its own web api?
Can I generate API keys or bearer tokens in AD that I can put in http headers to authorize this old client?

Thanks a mil

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

Accepted answer
  1. ajkuma 26,126 Reputation points Microsoft Employee
    2021-07-27T08:01:22.857+00:00

    @DaveVs , Thanks for sharing additional details.

    Easy Auth doesn't support static key-based authentication, but it does support validating Azure AD bearer tokens. For your legacy web app, you can use one of the MSAL libraries to fetch a bearer token from Azure AD and then attach it to an HTTP request to your web API configured with Easy Auth in the Authorization header (e.g. "Authorization: Bearer <jwt>").

    You can achieve this using the following guidance: https://learn.microsoft.com/azure/app-service/configure-authentication-provider-aad#daemon-client-application-service-to-service-calls

    Hope this helps point you in the right direction. If you any questions, please let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.