Auth0 回调 URL 不匹配 [英] Auth0 callback URL mismatch

查看:29
本文介绍了Auth0 回调 URL 不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 React 应用程序中使用 auth0 进行 LinkedIn 身份验证.我在设置中的回调 url 中设置了 localhost:3000/upload,在用户登录 localhost:3000/login 后,他们将被重定向到 localhost:3000/上传.但是,我总是收到此错误: 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 仪表板上,在 Settings -> Allowed Callback URLs 下放置您的回调条目 (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.

这篇关于Auth0 回调 URL 不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆