We have an Azure Static Web App with integrated /api
via Azure Function (linked backend). The frontend needs to know some properties of the authenticated user (like Job Title) but the /.auth/.me
endpoint only provides the userId
(Azure AAD GUID), userDetails
(email) and userRoles
.
How can we, either from the frontend (via fetch
to some Azure AAD/Entra API) or the backend (c#
) get more information about the logged-in user?
Note: Due to this missing feature, the frontend has no access to any access tokens.
Note: Azure Static Web Apps integrates authentication using Azure Active Directory (AAD) or other identity providers. When users authenticate, they receive a token that can be used to access APIs or other protected resources. However, the standard /.auth/me
endpoint, which is used to get details about the authenticated user, does not currently return the access token itself.
/.auth/me
.Hence as a workaround, you should make use of MSAL and generate the access token and then call Microsoft Graph API.
If the frontend does not have direct access to the necessary tokens, you can perform a request to the Microsoft Graph API from the Azure Function to retrieve additional information about the authenticated user.
Make sure to add user.read
API permission to the Microsoft Entra ID application:
And call the below query:
https://graph.microsoft.com/v1.0/me?$select=jobTitle,givenName,surname