Luca
Luca

Reputation: 11006

redirect URI in Azure web app authentication

I have browsed various questions here on SO, but none seem to have helped.

So, I have the following setup on Azure. I had a simple flask app running, which I could access using https://xyz.azurewebsites.net.

I was trying to look at the example here (https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-authentication-sample-python-web-app?tabs=linux). I can reproduce this example fine when I have the local server running and specifying the redirect uri as http://localhost:5000/getAToken.

Now, I want to use my deployed app, so I changed the redirect URI in the azure portal under authentication as

https://xyz.azurewebsites.net/getAToken

However, this always returns the redirect URI mismatch error.

On the flask side, I have kept the configuration as:

REDIRECT_PATH = "/getAToken"

Although I tried putting the full absolute URL as well and it did not work.

Upvotes: 1

Views: 978

Answers (1)

Harshitha
Harshitha

Reputation: 7392

I have followed the same document which you have provided and able to access the Application even after deploying to Azure App Service.

In app_config.py, change the authority_template to

authority_template = "https://{b2c_tenant}.b2clogin.com/{b2c_tenant}.onmicrosoft.com/{signupsignin_user_flow}"

OR

  • Copy paste the tenant and user_flow value directly.
authority_template  =  "https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{user_flow}"

Local Output: enter image description here

Deploy the Application to Azure App Service:

  • Create a new repository in GitHub and push the VSCode to it.

OR If you face any issues in pushing the code to Git.

  • Create a new repository, copy and clone the application which you have provided.

enter image description here

Your Repository: enter image description here

  • And change the values in app_config.py accordingly (from your local VSCode).

  • In Azure Portal => Create a new App Service with Run time Stack Python.

enter image description here

  • From Deployment center => Deploy the code using GitHub Actions.

enter image description here

  • Add the Redirect URI of the deployed Application in App registration.
https://YourDeployedAppName.azurewebsites.net/getAToken

Here my deployed app name is myadb2c.So, update the Redirect URI as below.

https://myadb2c.azurewebsites.net/getAToken

enter image description here

***Workflow in GitHub Repository: *** enter image description here

Deployed Application Output:

enter image description here

enter image description here

Upvotes: 1

Related Questions