Auth0 basic example has Invalid State error

I am a beginner in SSO as well as in Auth0.

I have created init.php page.
require “vendor/autoload.php”;

use Auth0\SDK\Auth0;

$auth0 = new Auth0([
‘domain’ => ‘iotians.us.auth0.com’,
‘client_id’ => ‘XXXXXXXXXXXXXXXXXX’,
‘client_secret’ => ‘bC-XXXXXXXXXXXXX-UGoYkyMM-ukMMn9j4x3CWGkmX6jlAoHS’,
‘redirect_uri’ => ‘http://localhost/00-starter-seed/callback.php’,
‘audience’ => ‘https://iotians.us.auth0.com/userinfo’,
‘persist_id_token’ => true,
‘persist_access_token’ => true,
‘persist_refresh_token’ => true,
‘scope’ => ‘openid profile’,
]);

and in callback.php file, I am trying to access logged-in information as below.
require “init.php”;

$userInfo = $auth0->getUser();

if (!$userInfo) {
die(“Error while logging you in. Please retry”);
} else {
var_dump($userInfo);
}

But I am getting error below:

Fatal error: Uncaught Auth0\SDK\Exception\CoreException: Invalid state in /var/www/html/00-starter-seed/vendor/auth0/auth0-php/src/Auth0.php:558 Stack trace: #0 /var/www/html/00-starter-seed/vendor/auth0/auth0-php/src/Auth0.php(480): Auth0\SDK\Auth0->exchange() #1 /var/www/html/00-starter-seed/callback.php(5): Auth0\SDK\Auth0->getUser() #2 {main} thrown in /var/www/html/00-starter-seed/vendor/auth0/auth0-php/src/Auth0.php on line 558

Good morning,

Is this an intermittent error or is it happening every login?
Can you please provide steps for reproduction? Did you just download the sdk (configure it) and are using that as is and you are experiencing this issue? What kind of connection is configured?

1 Like