Flask and Azure AD

I have followed the Azure AD integration tutorial and that seems to work - I can press the “test” button and get a success page with my login details.

Then I used the same connection with the downloadable React sample and got that to work by logging in, clicking on the “Microsoft” button, so I’m pretty confident that the integration as a whole is working.

Now I’m trying to use that integration to work with a Flask app, based on the tutorial here:

Auth0 Python SDK Quickstarts: Add login to your Python Flask app

I can use the Auth0 integration to login by logging in with a username and password and that seems to work. However, if I click the “login with Microsoft” button I get an error message from the Microsoft end saying “invalid_request: The provided value for the input parameter ‘redirect_uri’ is not valid. The expected value is a URI which matches a redirect URI registered for this client application.”

The page that carries the error has the following URL:

https://login.live.com/oauth20_authorize.srf?response_type=code&redirect_uri=https%3A%2F%2Flogin.uk.auth0.com%2Flogin%2Fcallback&scope=wl.signin&state=Fe26.2**4d5cfe04461f1ee3ab3009428ed7aed2dfed2a63004ab00c81a764174f8bd0fa*nMjKNu8Je3gRy1POHX4yPw*5a8NqvwLfV-4VqZJk3g2mD3i4NGxzv3XF4TcGtiGaZ5JM3mVjNBGzHsKWFIMc15DfMFtQr1CS2EzEHC3g3BUupZ5hKV0iX-j50UT-nO28k__mwi70V7qJlMJIVFHiijA**2527383771757d4b13792cd75713465538260f6082a74542a2c05334f640def2*5KIMejQHFN3UHD6q8kkbBNztRm9Us5SfWRSWNps-Xqs&client_id=XXXX-XXXX-XXXX-XXXX

So it looks like the redirect_uri is actually https://login.uk.auth0.com/login/callback, but I can’t see this URI mentioned in any of the tutorials I’ve followed up to this point, which always refer to my tenant domain. I’ve tried adding this login.uk.auth0… URI to the Azure AD configuration but that doesn’t seem to work either. Any suggestions?

Thanks,

Peter

OK, I fixed this. The problem was to do with the both the application and enterprise connection configuration at the Auth0 end.

First of all, in the application configuration on the Connections tab, I had mistakenly ticked the “windowslive” option. This is what was actually providing the “login with Microsoft” button on my login box, and was muddying the waters with the Azure AD connector I had created. Once I unchecked this option, there was no “login with Microsoft” button at all.

Then I had to go to the configuration for my Azure AD Enterprise connection and under the “login experience” tab, I had to check the box to “Display connection as a button”. Now the “login as Microsoft” button was back in my login box and actually using the Azure AD connection I had setup. Clicking this button then worked as expected.

1 Like

Wooohoooo! Perfect thanks for sharing it with the rest of community!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.