Authentication “vue认证”;错误:验证弹出窗口已关闭";
我正在尝试使用的oauth2提供程序和自定义axios响应拦截器进行身份验证,如下所示:Authentication “vue认证”;错误:验证弹出窗口已关闭";,authentication,oauth-2.0,vue-authenticate,Authentication,Oauth 2.0,Vue Authenticate,我正在尝试使用的oauth2提供程序和自定义axios响应拦截器进行身份验证,如下所示: bindRequestInterceptor() { this.$http.interceptors.request.use((config) => { console.log('Axios intercetping request') console.log(`Before checking Token : ${this.getToken()}`) i
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\u uri
我的问题是,为什么在这个流程之后我不能进行身份验证
。
事实上,如果我通过axios重新调用ajax,它将从授权流(批准窗口等)重新引导我
这里有人熟悉这个工具吗?以及如何解决这个问题
注意:当关闭approval窗口时,我在名为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