我正在用auth0在反应应用程序中进行LinkedIn身份验证。我在设置中设置了回拨URL中的localhost:3000/upload
,在用户登录localhost:3000/login
后跳转,他们将重定向到localhost:3000/upload
。但是,我总是得到这个错误:url localhost:3000/login
不在回调网址列表中。为什么auth0希望返回到登录后登录的页面?不是它应该是一些不同的URL。它对我来说没有意义。Auth0回调URL不匹配
编辑:
export default class AuthService {
constructor(clientId, domain) {
// Configure Auth0
const options = {
allowedConnections: ['linkedin'],
auth: {
params: {responseType: 'code'}
}
};
this.lock = new Auth0Lock(clientId, domain, options)
// Add callback for lock `authenticated` event
this.lock.on('authenticated', this._doAuthentication.bind(this))
// binds login functions to keep this context
this.login = this.login.bind(this)
this.loggedIn = this.loggedIn.bind(this)
}
_doAuthentication(authResult){
// Saves the user token
console.log(authResult);
this.setToken(authResult.idToken)
this.lock.getProfile(authResult.idToken, (error, profile) => {
if (error) {
console.log('Error loading the Profile', error)
} else {
console.log(profile)
}
})
}
//....
嘿,谢谢你的回答。我做了你的建议,但它仍然指引我进行身份验证的相同网址。 –
对于反应应用程序,您应该使用隐式授予流程......所以在这种情况下,请使用responseType = token并使用事件侦听器,因为您的操作是我的建议。合理? – arcseldon
@shangsunset - 你解决了吗? – arcseldon