Auth0回调URL不匹配
我在React应用中使用auth0进行LinkedIn身份验证.我在设置的回调URL中设置了localhost:3000/upload
,希望用户登录localhost:3000/login
后将其重定向到localhost:3000/upload
.但是,我总是收到此错误:url localhost:3000/login
不在回调URL列表中.为什么auth0希望在登录后返回到您刚刚登录的页面.应该不是其他URL.只是对我来说没有意义.
I am doing LinkedIn authentication with auth0 in a react app. I have set localhost:3000/upload
in callback urls in settings, hopping that after users login at localhost:3000/login
, they would be redirected to localhost:3000/upload
. However, I always get this error: url localhost:3000/login
is not in the list of callback urls. Why would auth0 expect to return to the page where you just logged in after logging in. Shouldn't it be some different url. It just does not make sense to me.
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).在您的应用程式程式码中
1). In your react app code
responseType: 'code'
2).在Auth0仪表板上的设置"->允许的回调URL"下,放置您的回调条目(localhost:3000/upload)-我认为您已经完成了,但以防万一.
2). On the Auth0 dashboard, under Settings -> Allowed Callback URLs put your callback entry (localhost:3000/upload) - which I think you have done but just in case.
如果您仍然遇到问题,请告诉我.
Let me know if you are still having problems.