Added Unauthorized redirect to basic usage

This commit is contained in:
William 'psyFi' Hatcher
2020-07-14 22:00:52 -05:00
committed by GitHub
parent d552a048ee
commit a0682fc192

View File

@@ -43,7 +43,7 @@ in exchange for fetching user's details and display them on web page.
.. code-block:: python3
from flask import Flask, redirect, url_for
from flask_discord import DiscordOAuth2Session, requires_authorization
from flask_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
app = Flask(__name__)
@@ -69,6 +69,11 @@ in exchange for fetching user's details and display them on web page.
return redirect(url_for(".me"))
@app.errorhandler(Unauthorized)
def redirect_unauthorized(e):
return redirect(url_for("login"))
@app.route("/me/")
@requires_authorization
def me():
@@ -85,4 +90,4 @@ in exchange for fetching user's details and display them on web page.
if __name__ == "__main__":
app.run()
app.run()