简体   繁体   English

在laravel 5.3中使用auth0

[英]Using auth0 with Laravel 5.3

I am trying to use auth0 with Laravel 5.3. 我正在尝试将auth0与Laravel 5.3一起使用。 I wrote following code 我写了以下代码

<script src="https://cdn.auth0.com/js/lock/10.2/lock.min.js"></script>
<script type="text/javascript">
  var lock = new Auth0Lock('M0pdPK3bUKwYuHzK3Lxx8CWEFtu0Qv2X', 'foysal.auth0.com', {
    auth: {
      redirectUrl: 'http://127.0.0.1/addbook/auth0/callback',
      responseType: 'code',
      params: {
        scope: 'openid email' // Learn about scopes: https://auth0.com/docs/scopes
      }
    }
  });
</script>

Here is my callback settings in auth0 这是我在auth0中的回调设置

在此处输入图片说明

But while I am trying to login I got below error 但是,当我尝试登录时,出现以下错误

在此处输入图片说明

Could any one say where is the issue ?? 谁能说出问题在哪里?

I might be wrong here, but I think you should define your GET variables in the route. 我在这里可能是错误的,但是我认为您应该在路由中定义GET变量。 This way you also keep the URL's nice and clean. 这样,您还可以保持URL的美观。

Route::get('auth0/callback/{code}', ['as' => 'logincallback', 'uses' => '\Auth0\Login\Auth0Controller@callback']);

Since it's a 404, try my above code and instead of doing ?code=xxx just add the code after the callback/ (Suggest to try both URL's) 由于它是404,请尝试上面的代码,而不是执行?code=xxx只需在callback/之后添加代码(建议尝试两个URL)

This javascript could make sure your url is valid: 这个JavaScript可以确保您的网址有效:

<script src="https://cdn.auth0.com/js/lock/10.2/lock.min.js"></script>
<script type="text/javascript">
   var lock = new Auth0Lock('M0pdPK3bUKwYuHzK3Lxx8CWEFtu0Qv2X', 'foysal.auth0.com', {
   auth: {
      redirectUrl: '{!!route('logincallback') !!}',
      responseType: 'code',
      params: {
        scope: 'openid email'
      }
    }
  });
</script>

Also, unless you have CORS errors in your console, there are no cors errors. 另外,除非您的控制台中有CORS错误,否则没有cors错误。 But if you stumble on them later it's probably because you are using 127.0.0.1 which could cause issues. 但是,如果稍后发现它们,可能是因为您使用的是127.0.0.1,这可能会导致问题。 In that case you should use localhost instead. 在这种情况下,您应该改用localhost。

I believe I had the same error. 我相信我也有同样的错误。 Did you put http://127.0.0.1 in the CORS accepted urls box. 您是否在CORS接受的网址框中输入了http://127.0.0.1 I believe it's in the same page as the callback urls. 我相信它与回调URL位于同一页面中。 That worked for me. 那对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM