Azure-Samples / ms-identity-python-webapp

A Python web application calling Microsoft graph that is secured using the Microsoft identity platform
MIT License
293 stars 138 forks source link

JSONDecodeError when running the identity sample app #148

Closed mattrochford closed 4 months ago

mattrochford commented 4 months ago

Hello,

I am working on a streamlit web app in Python that will be running on an EC2 instance. I am trying to set up SSO for our organization using Azure AD B2C and have been following the steps listed here:

https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-authentication-sample-python-web-app?tabs=windows

I have no issues with the first 4 steps but am running into an issue for step 5 when I try to run the sample web app. After executing 'python -m flask run --host localhost --port 5000' I receive a JSONDecodeError that looks like this:

image

I ran this both on an EC2 instance and on my local machine and each time the exact same error was produced. Can someone please point me in the right direction to get this working? Thank you

rayluo commented 4 months ago

Can you double check your configuration in .env to see whether you defined a REDIRECT_URI?

mattrochford commented 4 months ago

Can you double check your configuration in .env to see whether you defined a REDIRECT_URI?

Hi Ray,

Thank you so much for the quick response. This fixed everything right away. I do now see that in .env.sample.b2c the REDIRECT_URI is included but in the guide that I originally linked it is not. Perhaps it would be helpful to include it in the guide as well. Thanks again for your help and have a nice weekend.

Best, Matt

rayluo commented 4 months ago

FYI: Upgrade an underlying library by pip install -U identity to get its 0.8.1 version, and you will see a nicer error message when/if you forget to configure redirect_uri for your B2C authority.

Login Failure configuration_error This authority does not support device code flow. Please configure a redirect_uri to use auth code flow.