Answer a question

I created the sample Python Flask Webapp by following the below link.

https://docs.microsoft.com/en-us/azure/app-service/containers/quickstart-python?tabs=bash

I also added the AD Authentication for the Flask application by enabling Authentication in the Settings of the App Services. Now the app works only when the user is logged in and cannot access otherwise.

I would want to fetch the email id if the user who is logged in. I tried checking online but unable to find a way to get the email address of the user.

Any help is really appreciated.

Answers

App Service passes user claims to your application by using special headers. So you can get user information from the request header. Some example headers include:

  • X-MS-CLIENT-PRINCIPAL-NAME
  • X-MS-CLIENT-PRINCIPAL-ID

You can use res.headers to see all the values.

Reference:

Access user claims

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐