diff --git a/flask_discord/_http.py b/flask_discord/_http.py index 5d066d9..276d9a1 100644 --- a/flask_discord/_http.py +++ b/flask_discord/_http.py @@ -23,6 +23,11 @@ class DiscordOAuth2HttpClient(abc.ABC): """ + SESSION_KEYS = [ + "discord_oauth2_state", + "discord_oauth2_token", + ] + def __init__(self, client_id, client_secret, redirect_uri): self.client_id = client_id self.client_secret = client_secret diff --git a/flask_discord/client.py b/flask_discord/client.py index d03e6aa..d8279d7 100644 --- a/flask_discord/client.py +++ b/flask_discord/client.py @@ -59,6 +59,15 @@ class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient): ) session["discord_oauth2_token"] = token + def revoke(self): + """This method clears current discord token, state and all session data from flask + session . Which means user will have + to go through discord authorization token grant flow again. + + """ + for session_key in self.SESSION_KEYS: + session.pop(session_key) + def fetch_user(self): return models.User(self.get("/users/@me"))