我正在 React 应用程序中使用 auth0 进行 LinkedIn 身份验证。我已经设定localhost:3000/upload
在设置中的回调网址中,希望用户登录后localhost:3000/login
,他们将被重定向到localhost:3000/upload
。但是,我总是收到此错误: urllocalhost:3000/login
不在回调 url 列表中。为什么auth0登录后会期望返回到刚刚登录的页面。不应该是一些不同的url吗?这对我来说没有意义。
Edit:
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)
}
})
}
//....
请确保两件事:
1)。在你的反应应用程序代码中
responseType: 'code'
2)。在 Auth0 仪表板上,在“设置”->“允许的回调 URL”下放置您的回调条目 (localhost:3000/upload) - 我认为您已经这样做了,但以防万一。
如果您仍然遇到问题,请告诉我。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)