fallback to any user token instead of app token

This commit is contained in:
2025-01-18 12:38:33 +00:00
parent 5a95fe8bef
commit bb414c7de6
+3 -3
View File
@@ -189,8 +189,8 @@ export default class TwitchAuth {
* get the cached token * get the cached token
* @returns {Promise<TwitchToken>} * @returns {Promise<TwitchToken>}
*/ */
async getLocalToken(user_id=undefined){ async getLocalToken(user_id=await localStorage.key(0)){
const data=await localStorage.getItem(user_id||this.client_id)||globalThis.localStorage.getItem(import.meta.url) const data=await localStorage.getItem(user_id)||globalThis.localStorage.getItem(import.meta.url)
if(!data){ if(!data){
return null return null
} }
@@ -198,7 +198,7 @@ export default class TwitchAuth {
} }
async getAppToken(){ async getAppToken(){
let token=await this.getLocalToken() let token=await this.getLocalToken(this.client_id)
if(!token){ if(!token){
token=TwitchAuth.getAppToken(this.client_id) token=TwitchAuth.getAppToken(this.client_id)
token=await this.setToken(token) token=await this.setToken(token)