简体   繁体   中英

Auth0 “Invalid state” exception with Laravel 8 and Auth0 plugin 6.2

Recently upgraded our stack to use PHP 8 and Laravel 8.22 This required an upgrade within composer of the Auth0 library:

"auth0/login" from "5.4" to "6.2"

The code snippet that creates the error is this:

    /** @var Auth0Service $service */
    $service = App::make('auth0');
    $profile = $service->getUser();

When trying to get the user, the app fails with

Auth0\SDK\Exception\CoreException
Invalid state 

The Auth0 logs online show a successfull login

At this point I have no idea how to debug this… where should I start. Remember this was a perfectly fine working application before the version upgrade.

In the original question, the reason why I needed the user information was to be able to manually create a loginUrl for Auth0.

This ended up working fine with the following code

    $loginUrl = (new Auth0([
        'audience' => 'http://my-own-audience.test/',
    ]))->getLoginUrl();

Because we were extending some of the Auth0 functionality we had an issue of not creating the proper information with our extended classes for the login url. So instead of fixing our classes we just ended up using more of the Auth0 code which works fine.

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