Skip to content

Commit 0ce9218

Browse files
committed
fix(oauth): properly validate broadcaster token before api call
1 parent 7baa495 commit 0ce9218

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ class API extends Core {
198198
isBlocking = fnc;
199199

200200
// run validation before any requests
201-
if (!(await oauth.validateOAuth('bot') || await oauth.validateOAuth('broadcaster'))) {
201+
const[ botValidation, broadcasterValidation ] = await Promise.all(oauth.validateTokens());
202+
if (!botValidation || !broadcasterValidation) {
202203
continue;
203204
}
204205

src/oauth.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ class OAuth extends Core {
119119

120120
@onStartup()
121121
onStartup() {
122-
this.validateOAuth('bot');
123-
this.validateOAuth('broadcaster');
122+
this.validateTokens();
124123
this.getChannelId();
125124
}
126125

126+
validateTokens() {
127+
return [this.validateOAuth('bot'), this.validateOAuth('broadcaster')];
128+
}
129+
127130
@onLoad('broadcasterAccessToken')
128131
@onLoad('botAccessToken')
129132
setBotAccessTokenLoaded() {

0 commit comments

Comments
 (0)