Closed ragehegy closed 4 years ago
Also the line
app.jinja_env.globals.update(_build_auth_url=_build_auth_url)
shows an error 'Method 'jinja_env' has no 'globals' member'
This sounds like a dependency environment issue. What is the pip list
output of your environment? In particular, what is the version numbers for our direct dependencies here?
For example, my environment currently contains:
$ pip list
...
Flask 1.1.2
Flask-Session 0.3.2
...
msal 1.1.0
...
requests 2.22.0
...
Werkzeug 1.0.1
...
You do NOT have to use exact same versions as I do, but please let us know if you believe your particular combination does not work, so that we can investigate.
Thanks for fast reply @rayluo. I already had my own combination which worked fine for a regular flask applications. I tried your combination since mine didn't work.
The following error while trying to install flask-oauthlib:
ERROR: flask-oauthlib 0.9.5 has requirement oauthlib!=2.0.3,!=2.0.4,!=2.0.5,<3.0.0,>=1.1.2, but you'll have oauthlib 3.1.0 which is incompatible.
Alternatively, I reinstalled the oauthlib with version 2.1.0 and got another error related to requests-oauthlib:
ERROR: requests-oauthlib 1.3.0 has requirement oauthlib>=3.0.0, but you'll have oauthlib 2.1.0 which is incompatible.
And still have the jinja_env error.
here's how my app requirements.txt looks like atm:
Flask>=1,<2 Flask-Session>=0,<1 requests>=2,<3 msal>=0,<2
terminal output
tracing this lines
if request.args.get('state') != session.get("state"):
return redirect(url_for("index"))
shows that the session object doesn't persist the state value after clicking login. It's always 'none', while the request.args.get('state') does have the original state session value.
Now it's working thanks to https://stackoverflow.com/questions/61602426/python-and-azuread-with-flask-ms-identity-python-webapp-example-only-logging-i i installed the flask-session from https://github.com/rayluo/flask-session and it finally got to work!
Glad that you manage to make it work.
With regarding to the flask-session
, you did an amazing research job on finding my workaround :-) But that shouldn't be necessary. An indirect upstream module, cachelib, released a relevant bugfix at about the same time you posted this issue. So now this sample can probably work out-of-box, if you deploy it in a freshly-installed environment.
Lastly, I happen to notice you committed your client_secret (among many temporary sessions which contains tokens in themselves) into your project repo. It is highly recommended that you remove them from repo, change your client_secret.
Lastly, I happen to notice you committed your client_secret (among many temporary sessions which contains tokens in themselves) into your project repo. It is highly recommended that you remove them from repo, change your client_secret.
My bad! Thanks for this tip. and thanks for your efforts, appreciate it.
My app always loads the index file with login button after successful authentication. Terminal shows the getAToken called with the code and status strings, but it always redirects to the index. i just clonned the repo and changed the config parameters as per my registered app. Also the line
app.jinja_env.globals.update(_build_auth_url=_build_auth_url)
shows an error 'Method 'jinja_env' has no 'globals' member' Full app.py