sha*_*set 8 authentication reactjs social-authentication auth0
我在反应应用程序中使用auth0进行LinkedIn身份验证.我在设置localhost:3000/upload
中设置了回调网址,在用户登录后localhost:3000/login
跳转,他们将重定向到localhost:3000/upload
.但是,我总是收到此错误:url localhost:3000/login
不在回调网址列表中.为什么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)
}
})
}
//....
Run Code Online (Sandbox Code Playgroud)
请确保两件事:
1)。在您的应用程式程式码中
responseType: 'code'
Run Code Online (Sandbox Code Playgroud)
2)。在Auth0仪表板上的“设置”->“允许的回调URL”下,放置您的回调条目(localhost:3000 / upload)-我认为您已经这样做了,以防万一。
如果您仍有问题,请告诉我。
归档时间: |
|
查看次数: |
11424 次 |
最近记录: |