vue应用程序中auth0实现中的无效状态错误

问题描述

有人知道 auth0 帮助我! 我们的应用是使用 typescript 上的 vue / vuex 构建的,并处理来自外部api的大量数据。

我们没有任何单独的登录URL,只是我们的第一页是重定向URL本身,并且第一页是调用外部api来消耗要显示在其上的数据。

以下是重定向处理部分:

//action
  async handleRedirectCallback({commit,dispatch}){
    //here we use auth0 service,which is also attached below this code block
    return auth0.handleRedirectCallback().then(async (token: string) => {
      commit("sessionCreate",token)
      return auth0.getUser(token).then((res: AxiosResponse) => {
        commit("setUser",res.data)
        commit("loaded",true)
        return Promise.resolve(res);
      })
    }).catch((auth: boolean) =>{
      window.console.log(`${auth}`)
    })
  }
//In auth0 service
  async handleRedirectCallback(){
    let token;
    let isAuthenticated = false
    try {
      if (
        window.location.search.includes("code=") &&
        window.location.search.includes("state=")
      ) {
        const { appState } = await this.auth0Client.handleRedirectCallback();
        options.onRedirectCallback(appState);
      }
    } catch (e) {
      return Promise.reject(e)  //Here I got rejected!
    } finally {
      isAuthenticated = await this.isAuthenticated();
      if(isAuthenticated){
        token = await this.getTokenSilently();
      }
    }
    if(token){
      return Promise.resolve(token)
    }
    return Promise.reject(isAuthenticated)
  }

它显示错误:首次加载重定向URL时出现无效状态;如果刷新页面,它可以正常工作,除此问题外,一切都很好。

问题是由于无效状态错误导致外部api调用失败,因为我们需要使用来自auth0的凭据来调用外部api。

任何帮助将不胜感激。 预先感谢!

编辑: 在继续调试时,我发现此承诺被拒绝了:(

auth0Client.handleRedirectCallback();

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...