We are developing a mobile app which will call azure functions to get and post data. For our proof of concept, we have deployed a Microsoft sample java function app called HTTPExample which expects a parameter called name. The name value will appear in the response.
The function executes correctly when App Service Authentication is off. I verified using Code + Test and Postman. The authentication level is anonymous.
I'm having issues with the token after App Service Authentication is enabled. The response is 401 Unauthorized - You do not have permission to view this directory or page. This is a common issue on the message boards but haven't found a resolution that works for us.
Below are the steps I'm taking to obtain an token and execute the function app.
Using postman, my first step is to retrieve an authorization code
https://login.microsoftonline.com//oauth2/v2.0/authorize?client_id=e19cccb7-b693-486f-b4c2-286ed1f17dda&response_type=code&response_mode=query&prompt=consent&redirect_uri=https%3A%2F%2Flocalhost%3A4200%2F&scope=user.read
The authorization code is successfully returned. My second step is to get the access token using https://login.microsoftonline.com//oauth2/v2.0/token as shown in the screenshot.
In the final step, I take the access_token provided in the output and pass to my function app in the header. The key is authorization and the value is Bearer . Below is a screenshot. As you can see, it failed.
I inspected the token payload. The aud and appid are the same. The value is the client id. Initially, I excluded scope so aud and appid did not match.