Is Flask OIDC Sample Broken?

It appears as though this sample samples-python-flask/okta-hosted-login at master · okta/samples-python-flask · GitHub is broken, at least for me, in Python 3.11.x

Firstly: it did not have a couple of required imports (easy enough to fix)
Secondly: it generates the following error message:

Traceback (most recent call last):
  File "\okta-hosted-login\main.py", line 6, in <module>
    from flask import Flask, render_template, redirect, request, url_for
  File "\.venv\Lib\site-packages\flask\__init__.py", line 19, in <module>
    from jinja2 import Markup, escape
ImportError: cannot import name 'Markup' from 'jinja2' (\.venv\Lib\site-packages\jinja2\__init__.py)

I strongly suspect that this is a dependency version issue.
The requirements supplied on GitHub has:

requests==2.21.0
Flask==1.0.2
flask-cors==3.0.10
pyOpenSSL==23.2.0
Flask-Login==0.4.1
okta-jwt-verifier==0.2.0

If I run pip freeze after installing the requirements I see:

acachecontrol==0.3.5
aiohttp==3.9.3
aiosignal==1.3.1
attrs==23.2.0
certifi==2024.2.2
cffi==1.16.0
chardet==3.0.4
click==8.1.7
colorama==0.4.6
cryptography==41.0.7
decorator==5.1.1
ecdsa==0.18.0
Flask==1.0.2
Flask-Cors==3.0.10
Flask-Login==0.4.1
frozenlist==1.4.1
idna==2.8
itsdangerous==2.1.2
Jinja2==3.1.3
markup==0.2
MarkupSafe==2.1.5
multidict==6.0.5
okta-jwt-verifier==0.2.0
py==1.11.0
pyasn1==0.5.1
pycparser==2.21
pyOpenSSL==23.2.0
python-jose==3.3.0
requests==2.21.0
retry==0.9.2
rsa==4.9
six==1.16.0
urllib3==1.24.3
Werkzeug==3.0.1
yarl==1.9.4

It’s probably a matter of using an older version of Markup and/or jinja2 and/or Python.
Maybe I’m just unlucky.
I guess we’ll see what happens.

By changing the requirements.txt to the following the sample flask project works enough for it to be started.

acachecontrol==0.3.5
aiohttp==3.9.3
aiosignal==1.3.1
attrs==23.2.0
blinker==1.7.0
certifi==2024.2.2
cffi==1.16.0
chardet==3.0.4
click==7.1.2
colorama==0.4.6
cryptography==41.0.7
decorator==5.1.1
ecdsa==0.18.0
Flask==1.1.4
Flask-Cors==3.0.10
Flask-Login==0.4.1
frozenlist==1.4.1
idna==2.8
itsdangerous==1.1.0
Jinja2==2.11.0
markup==0.2
MarkupSafe==2.0.1
multidict==6.0.5
okta-jwt-verifier==0.2.0
py==1.11.0
pyasn1==0.5.1
pycparser==2.21
pyOpenSSL==23.2.0
python-jose==3.3.0
requests==2.21.0
retry==0.9.2
rsa==4.9
six==1.16.0
urllib3==1.24.3
Werkzeug==1.0.1
yarl==1.9.4

Good catch, Pete! I reached out to the team that maintains that sample and we are looking to update it.

I know @alisaduncan already shared this with you, but in the meantime, you or anyone else wanting a Flask sample can use this quickstart: GitHub - okta-samples/okta-flask-sample: Python Flask + Okta

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