diff --git a/server/src/utils/TwitchAuth.ts b/server/src/utils/TwitchAuth.ts index 137a6a1..6718cd1 100644 --- a/server/src/utils/TwitchAuth.ts +++ b/server/src/utils/TwitchAuth.ts @@ -8,7 +8,6 @@ export class TwitchAuth { private token_type: string; private scope: string; private expires_in: number; - private invalidated: boolean = false; private _bid: string | undefined; constructor(token_data: TokenData) { @@ -113,11 +112,7 @@ export class TwitchAuth { * @param conf The Axios RequestConfig, without method, url, or baseURL * @returns The data returned from the Twitch API */ - public async request(method: Method, url: string, conf:any={}): Promise { - - if (this.invalidated) { - throw new Error("Can't make a request with an invalidated token"); - }; + public async request(method: Method, url: string, conf:any={}, attempt=0): Promise { try { let headers = { @@ -148,6 +143,9 @@ export class TwitchAuth { switch (err.response.status) { case 403: this.refresh(); + if (attempt < 3) { + this.request(method, url, conf, ++attempt); + }; break; default: log.error(err);