Skip to content
Advertisement

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

Auth0SDKExceptionCoreException
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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement