简体   繁体   中英

Using auth0 with Laravel 5.3

I am trying to use auth0 with 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

在此处输入图片说明

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. This way you also keep the URL's nice and clean.

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)

This javascript could make sure your url is valid:

<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. But if you stumble on them later it's probably because you are using 127.0.0.1 which could cause issues. In that case you should use localhost instead.

I believe I had the same error. Did you put http://127.0.0.1 in the CORS accepted urls box. I believe it's in the same page as the callback urls. That worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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