fallback to any user token instead of app token
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user