From 40d12f73820a1053c02bb74b01f7ef55f024bf2c Mon Sep 17 00:00:00 2001 From: derrod Date: Sat, 24 Jun 2023 03:43:01 +0200 Subject: [PATCH] UI: Invalidate Twitch token when disconnecting --- UI/auth-twitch.cpp | 10 ++++++++++ UI/auth-twitch.hpp | 1 + 2 files changed, 11 insertions(+) diff --git a/UI/auth-twitch.cpp b/UI/auth-twitch.cpp index 386a0e9275cc9a..f9ab41ef6dbdc0 100644 --- a/UI/auth-twitch.cpp +++ b/UI/auth-twitch.cpp @@ -24,6 +24,7 @@ using namespace json11; #define TWITCH_AUTH_URL OAUTH_BASE_URL "v1/twitch/redirect" #define TWITCH_TOKEN_URL OAUTH_BASE_URL "v1/twitch/token" +#define TWITCH_REOKVE_URL "https://id.twitch.tv/oauth2/revoke" #define TWITCH_SCOPE_VERSION 1 @@ -499,6 +500,15 @@ std::shared_ptr TwitchAuth::Login(QWidget *parent, const std::string &) return nullptr; } +void TwitchAuth::DeleteInternal() +{ + std::string client_id = TWITCH_CLIENTID; + deobfuscate_str(&client_id[0], TWITCH_HASH); + + InvalidateToken(TWITCH_REOKVE_URL, client_id); + OAuthStreamKey::DeleteInternal(); +} + static std::shared_ptr CreateTwitchAuth() { return std::make_shared(twitchDef); diff --git a/UI/auth-twitch.hpp b/UI/auth-twitch.hpp index 152b2a95730fd7..6ee781f8aefff7 100644 --- a/UI/auth-twitch.hpp +++ b/UI/auth-twitch.hpp @@ -24,6 +24,7 @@ class TwitchAuth : public OAuthStreamKey { virtual void SaveInternal() override; virtual bool LoadInternal() override; + virtual void DeleteInternal() override; bool MakeApiRequest(const char *path, json11::Json &json_out); bool GetChannelInfo();