'Callback URI Mismatch when using Auth0 with flask
I am using this tutorial to integrate Auth0 integration in my flask app.
I have specified https://localhost:3000/, https://localhost:3000/callback
URLs in my callback URLs.
This is the code for the routes as specified in the tutorial
## login route
@app.route("/login")
def login():
return oauth.auth0.authorize_redirect(
redirect_uri=url_for("callback",_external=True)
)
## callback route
@app.route("/callback", methods=["GET", "POST"])
def callback():
token = oauth.auth0.authorize_access_token()
session["user"] = token
return redirect("/")
## logout route
@app.route("/logout")
def logout():
session.clear()
return redirect(
"https://" + env.get("AUTH0_DOMAIN")
+ "/v2/logout?"
+ urlencode(
{
"returnTo": url_for("home", _external=True),
"client_id": env.get("AUTH0_CLIENT_ID"),
},
quote_via=quote_plus,
)
)
## home route
@app.route("/")
def home():
return render_template("home.html", session=session.get('user'), pretty=json.dumps(session.get('user'), indent=4))
home.html is a template for logging in.
When I'm running the flask app and trying to login,it is showing Callback URL mismatch, The provided redirect_uri is not in the list of allowed callback URLs. I know the error message is pretty straightforward but I have allowed the callback URL to be allowed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
