Skip to content

Commit 20f7f2f

Browse files
committed
UI: Invalidate OAuth tokens when disconnecting accoun account
1 parent 2b1aa58 commit 20f7f2f

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

UI/auth-restream.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ using namespace json11;
2121

2222
#define RESTREAM_AUTH_URL OAUTH_BASE_URL "v1/restream/redirect"
2323
#define RESTREAM_TOKEN_URL OAUTH_BASE_URL "v1/restream/token"
24+
#define RESTREAM_REVOKE_URL "https://api.restream.io/oauth/revoke"
2425
#define RESTREAM_STREAMKEY_URL "https://api.restream.io/v2/user/streamKey"
2526
#define RESTREAM_SCOPE_VERSION 1
2627

@@ -129,6 +130,12 @@ bool RestreamAuth::LoadInternal()
129130
return OAuthStreamKey::LoadInternal();
130131
}
131132

133+
void RestreamAuth::DeleteInternal()
134+
{
135+
InvalidateToken(RESTREAM_REVOKE_URL, "");
136+
OAuthStreamKey::DeleteInternal();
137+
}
138+
132139
void RestreamAuth::LoadUI()
133140
{
134141
if (uiLoaded)

UI/auth-restream.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class RestreamAuth : public OAuthStreamKey {
1313

1414
virtual void SaveInternal() override;
1515
virtual bool LoadInternal() override;
16+
virtual void DeleteInternal() override;
1617

1718
bool GetChannelInfo();
1819

UI/auth-twitch.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using namespace json11;
2424

2525
#define TWITCH_AUTH_URL OAUTH_BASE_URL "v1/twitch/redirect"
2626
#define TWITCH_TOKEN_URL OAUTH_BASE_URL "v1/twitch/token"
27+
#define TWITCH_REOKVE_URL "https://id.twitch.tv/oauth2/revoke"
2728

2829
#define TWITCH_SCOPE_VERSION 1
2930

@@ -499,6 +500,15 @@ std::shared_ptr<Auth> TwitchAuth::Login(QWidget *parent, const std::string &)
499500
return nullptr;
500501
}
501502

503+
void TwitchAuth::DeleteInternal()
504+
{
505+
std::string client_id = TWITCH_CLIENTID;
506+
deobfuscate_str(&client_id[0], TWITCH_HASH);
507+
508+
InvalidateToken(TWITCH_REOKVE_URL, client_id);
509+
OAuthStreamKey::DeleteInternal();
510+
}
511+
502512
static std::shared_ptr<Auth> CreateTwitchAuth()
503513
{
504514
return std::make_shared<TwitchAuth>(twitchDef);

UI/auth-twitch.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class TwitchAuth : public OAuthStreamKey {
2424

2525
virtual void SaveInternal() override;
2626
virtual bool LoadInternal() override;
27+
virtual void DeleteInternal() override;
2728

2829
bool MakeApiRequest(const char *path, json11::Json &json_out);
2930
bool GetChannelInfo();

UI/auth-youtube.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ using namespace json11;
3333
/* ------------------------------------------------------------------------- */
3434
#define YOUTUBE_AUTH_URL "https://accounts.google.com/o/oauth2/v2/auth"
3535
#define YOUTUBE_TOKEN_URL "https://www.googleapis.com/oauth2/v4/token"
36+
#define YOUTUBE_REVOKE_URL "https://oauth2.googleapis.com/revoke"
3637
#define YOUTUBE_SCOPE_VERSION 1
3738
#define YOUTUBE_API_STATE_LENGTH 32
3839
#define SECTION_NAME "YouTube"
@@ -188,6 +189,12 @@ bool YoutubeAuth::LoadInternal()
188189
return implicit ? !token.empty() : !refresh_token.empty();
189190
}
190191

192+
void YoutubeAuth::DeleteInternal()
193+
{
194+
InvalidateToken(YOUTUBE_REVOKE_URL);
195+
OAuthStreamKey::DeleteInternal();
196+
}
197+
191198
#ifdef BROWSER_AVAILABLE
192199
static const char *ytchat_script = "\
193200
const obsCSS = document.createElement('style');\

UI/auth-youtube.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class YoutubeAuth : public OAuthStreamKey {
4949
virtual bool RetryLogin() override;
5050
virtual void SaveInternal() override;
5151
virtual bool LoadInternal() override;
52+
virtual void DeleteInternal() override;
5253
virtual void LoadUI() override;
5354

5455
QString GenerateState();

0 commit comments

Comments
 (0)