authentication - vue-authenticate “错误:验证弹出窗口关闭”
问题描述
我正在尝试使用带有自定义 axios 响应拦截器的vue-authenticate的 oauth2 提供程序进行身份验证,如下所示:
bindRequestInterceptor() {
this.$http.interceptors.request.use((config) => {
console.log('Axios intercetping request')
console.log(`Before checking Token : ${this.getToken()}`)
if (this.isAuthenticated()) {
console.log('Authenticated')
config.headers.Authorization = [
this.options.tokenType, this.getToken(),
].join(' ')
} else {
console.log('Not authenticated')
delete config.headers.Authorization
let this_ = this;
this.authenticate('oauth2').then(function(authResponse){
console.log(authResponse)
this_.isAuthenticated = this_.$auth.isAuthenticated();
})//This fires an oauth popup window
}
console.log(`After checking Token : ${this.getToken()}`)
return config
})
},
运行 ajax 调用时: - 我在新窗口中被重定向到我的授权 url ( /oauth/authorize
) - 批准后,我成功地使用授权代码重定向到我的自定义。redirect_uri
我的问题是,为什么我不能authenticated
在这个流程之后。事实上,如果我通过 axios 重新调用 ajax,它会从授权流程(批准窗口等)中重新循环我
这里有没有人熟悉这个工具,以及如何解决这个问题?
注意:当关闭审批窗口时,我在调用 ajax 的页面中收到此错误
Possible Unhandled Promise Rejection: Error: Auth popup window closed
注2:根据上述代码的控制台日志
Axios intercetping request
app.js?id=01021d92b5ff42f0b696:30471 Before checking Token : null
app.js?id=01021d92b5ff42f0b696:30479 Not authenticated
app.js?id=01021d92b5ff42f0b696:30487 After checking Token : null
解决方案
推荐阅读
- arrays - 在 Flutter 中将数组解析为字符串并返回
- jquery - 如何通过 JQuery 查找和禁用按钮
- python-3.x - 如何在 pyomo 中使用 cbc 时将解决方案写入 .sol 文件?求解模型后如何获取 .sol 文件的名称?
- java - 无法在类上找到适当的构造函数
- mysql - Mysql查询加速计算10M行的关键
- android - RxJava 将发布主题与超时相结合
- c# - 如何查看存储在 Couchbase lite 中的数据文档?
- siddhi - 无法在 Siddhi 中使用“正则表达式”http.status.code 处理响应
- wix - windows-installer 检查是否需要修复
- postgresql - 如何在 PostgreSql 函数的返回表中设置标识列?