I have a very basic web app I am trying to deploy on an AWS with nginx, gunicorn, and flask. I can get the page to redirect to auth0 to sign in and make the call back. After that, in my gunicorn log I see what boils down to requests.exceptions.MissingSchema: Invalid URL 'None': No scheme supplied. Perhaps you meant https://None?
, but I cannot figure out where I have not defined a URL.
Any help appreciated!
Nginx.conf (excerpt):
server {
listen 443 ssl;
server_name DOMAIN.com www.DOMAIN.com;
root /var/www/DOMAIN;
location /{
proxy_pass http://unix:/var/www/DOMAIN/gunicorn.sock;
include /etc/nginx/proxy_params;
}
location @backend {
proxy_pass http://unix:/var/www/DOMAIN/gunicorn.sock;
include /etc/nginx/proxy_params;
}
#listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/DOMAIN.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/DOMAIN.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
access_log /var/log/nginx/DOMAIN.log;
error_log /var/log/nginx/DOMAIN-error.log;
}
app.py (start and callback route)
from flask import Flask, render_template, request, redirect, url_for, session
from authlib.integrations.flask_client import OAuth
import sqlite3
app = Flask(__name__)
app.secret_key = 'your_secret_key' # Change this to a random, secure key
oauth = OAuth(app)
oauth.register(
name='auth0',
client_id='private',
client_secret='',
authorize_url='https://DOMAIN.us.auth0.com/authorize',
authorize_params=None,
authorize_prompt=None,
authorize_response=None,
token_url='https://DOMAIN.us.auth0.com/oauth/token',
token_params=None,
client_kwargs={'scope': 'openid profile email'},
userinfo_endpoint='https://DOMAIN.us.auth0.com/userinfo',
callback_uri='https://DOMAIN.com/callback',
)
###other
@app.route('/callback', methods=["GET", "POST"])
def callback():
print("###############################")
token = oauth.auth0.authorize_access_token()
resp = oauth.auth0.get('userinfo')
user_info = resp.json()
session['profile'] = user_info
return redirect(url_for('index'))