Function App Authentication Token

Ho, Keith D 80 Reputation points
2024-05-21T22:01:20.77+00:00

I am currently in the process of setting up authentication for my Azure Function App, following these steps: https://learn.microsoft.com/en-us/azure/app-service/scenario-secure-app-authentication-app-service?tabs=workforce-configuration. I've followed all the steps and when I try to access the API, I get a 401 unauthorized response which is what I set the authentication to return. Now that the authentication is set up, I'm not sure how to retrieve an authentication token so that I can get through the 401 response.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,426 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 26,321 Reputation points Microsoft Employee
    2024-05-22T13:19:33.0466667+00:00

    Hi @Ho, Keith D

    When it comes to retrieving the token, it depends on the provider you configured. The endpoint will be /.auth/login/<provider>. As an example, if you're provider was Entra, then endpoint would /.auth/login/aad.

    The request will be redirect to the login page of the audience and tenant you configured. When the request is authenticated, the token gets stored on your function app for that session and is used for subsequent requests. Authentication and authorization - Azure App Service | Microsoft Learn goes into this in greater detail.