# Invalid State Error after Upgrading from Auth0 PHP SDK v7 to v8

**URL:** <https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-php\
**Created:** [July 22, 2024, 3:24pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435 "2024-07-22T15:24:34Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 23, 2024, 6:47pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/21 "2024-07-23T18:47:36Z")

</div>

Hi @yrmallu 👋

> I removed composer.lock and vendor and installed composer freshly but still getting the same error.  
> The error is coming on `$auth0->exchange()`

The error still being the one you posted above about the GuzzleHttp issue, correct?

That makes sense since `exchange()` opens and establishes a network connection, but we don’t include any hard dependencies, so Guzzle isn’t coming from our end. The SDK will use whatever is available within your project.

Can you share the contents of your `composer.json` here? Maybe we can spot something amiss there.

---

<div class="post-metadata">

**Author:** ![yrmallu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yrmallu/32/58746_2.png) [@yrmallu](https://community.auth0.com/u/yrmallu)\
**Post date:** [July 23, 2024, 6:52pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/22 "2024-07-23T18:52:04Z")

</div>

Hi @evansims,

Here the composer.json file

```auto
{
    "config": {
        "allow-plugins": {
            "php-http/discovery": true
        }
    },
    "require": {
        "auth0/auth0-php": "^8.11",
        "nyholm/psr7": "^1.8"
    }
}

```

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 23, 2024, 7:15pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/23 "2024-07-23T19:15:39Z")

</div>

Ah, I guess it must be `php-http/discovery` causing it to be installed. I’ve never seen it cause issues quite like that, but I don’t recommend using it, anyway.

Go ahead and set `php-http/discovery` to `false` in your `composer.json`. Then repeat deleting your `composer.lock` file and `vendor` subdirectory, and then try re-running `composer install`. That should take care of that Guzzle error, at least.

Next, the SDK requires PSR-7, PSR-17, and PSR-18 dependencies for creating, sending, and handling network requests.

Right now, you have `nyholm/psr7` imported, which is a great library and takes care of the PSR-7 and PSR-17 requirements. In addition, [you’ll also require a dependency that handles PSR-18](https://github.com/auth0/auth0-PHP/blob/main/FAQ.md#what-is-psr-18). There are [plenty of options out there](https://packagist.org/providers/psr/http-client-implementation) but I’m fond of [kriswallsmith/buzz](https://packagist.org/packages/kriswallsmith/buzz) just because it’s so lightweight. You can add it to your project by running `composer require kriswallsmith/buzz`.

That should (fingers crossed) resolve those networking woes.

---

<div class="post-metadata">

**Author:** ![yrmallu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yrmallu/32/58746_2.png) [@yrmallu](https://community.auth0.com/u/yrmallu)\
**Post date:** [July 23, 2024, 7:22pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/24 "2024-07-23T19:22:07Z")

</div>

@evansims. Thanks for the response.

Still same issue

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 23, 2024, 7:22pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/25 "2024-07-23T19:22:59Z")

</div>

You’re still getting a GuzzleHTTP error, specifically?

---

<div class="post-metadata">

**Author:** ![yrmallu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yrmallu/32/58746_2.png) [@yrmallu](https://community.auth0.com/u/yrmallu)\
**Post date:** [July 23, 2024, 7:24pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/26 "2024-07-23T19:24:39Z")

</div>

@evansims  
If I use Buzz

```auto
TypeError: Auth0\SDK\Configuration\SdkConfiguration::__construct(): Argument #20 ($httpClient) must be of type ?Psr\Http\Client\ClientInterface, Buzz\Client\MultiCurl given, called in /var/www/html/whmcs/modules/addons/auth0/auth0.php on line 116 and defined in /var/www/html/whmcs/modules/addons/auth0/vendor/auth0/auth0-php/src/Configuration/SdkConfiguration.php:116
Stack trace:

```

other wise

```auto
Whoops\Exception\ErrorException: Declaration of GuzzleHttp\Psr7\Request::getRequestTarget() must be compatible with Psr\Http\Message\RequestInterface::getRequestTarget(): string in /var/www/html/whmcs/vendor/guzzlehttp/psr7/src/Request.php:58
Stack trace:
#0 /var/www/html/whmcs/vendor/whmcs/whmcs-foundation/lib/Utility/Error/Run.php(0): WHMCS\Utility\Error\Run->handleError()
#1 [internal function]: WHMCS\Utility\Error\Run->handleShutdown()
#2 {main}

```

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 23, 2024, 7:37pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/27 "2024-07-23T19:37:11Z")

</div>

@yrmallu OK, I’m honestly quite baffled here.

> If I use Buzz

Internally, our SDK uses [psr-discovery/http-client-implementations](https://packagist.org/packages/psr-discovery/http-client-implementations) to discover available PSR-18 dependencies in your project without requiring you to configure anything. They’re used just by merit of existing in your project. So, in the case of `kriswallsmith/buzz`, [it expressly imports](https://github.com/psr-discovery/http-client-implementations/blob/1.x/src/Implementations/Psr18/Clients.php#L109) `Buzz/Client/FileGetContents`, not `Buzz/Client/MultiCurl`. I don’t know how, where, or why `MultiCurl` would be getting imported at all.

> other wise

I’m not sure I follow. Do you mean you get that exception even with `php-http/discovery` set to `false` if `kriswallsmith/buzz` is not installed?

In your `vendor` subdirectory, is there `guzzle` or `guzzlehttp` directory in there?

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 23, 2024, 7:38pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/28 "2024-07-23T19:38:09Z")

</div>

I have not heard of WHMCS before, but it’s beginning to sound like they’re somehow injecting their own dependencies into the environment beyond your control, and they’re conflicting. It’s the only thing I can think of that would cause this sort of thing.

---

<div class="post-metadata">

**Author:** ![yrmallu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yrmallu/32/58746_2.png) [@yrmallu](https://community.auth0.com/u/yrmallu)\
**Post date:** [July 23, 2024, 7:40pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/30 "2024-07-23T19:40:15Z")

</div>

I disabled php-http/discovery

---

<div class="post-metadata">

**Author:** ![evansims](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evansims/32/27011_2.png) [@evansims](https://community.auth0.com/u/evansims)\
**Post date:** [July 23, 2024, 7:51pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/31 "2024-07-23T19:51:09Z")

</div>

Please keep me up to date on any alterations you’re making so we can troubleshoot this successfully. My only awareness of your application’s state is in the context of what you’ve shared with me here, so when you make changes we haven’t discussed, I’m flying blind.

Can you share what your Auth0 SDK initialization/configuration looks like right now? You mentioned manually importing `MultiCurl` — we don’t want to be doing that here. Let’s get a clean look at your configuration.

---

<div class="post-metadata">

**Author:** ![yrmallu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yrmallu/32/58746_2.png) [@yrmallu](https://community.auth0.com/u/yrmallu)\
**Post date:** [July 23, 2024, 7:55pm UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/32 "2024-07-23T19:55:35Z")

</div>

@evansims Thanks a lot for your support.

It seems I fixed the issue but not sure if any issues will occur in future.

---

<div class="post-metadata">

**Author:** ![jack1111](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jack1111/32/57497_2.png) [@jack1111](https://community.auth0.com/u/jack1111)\
**Post date:** [July 29, 2024, 9:53am UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/33 "2024-07-29T09:53:40Z")

</div>

When upgrading from Auth0 PHP SDK v7 to v8, encountering an “Invalid State Error” typically indicates issues with session handling or state parameter verification[.](https://sssmidportal.com/) Ensure session storage is properly configured and state parameter handling aligns with the new SDK’s requirements to resolve this error.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 12, 2024, 9:54am UTC](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435/34 "2024-08-12T09:54:29Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://community.auth0.com/t/invalid-state-error-after-upgrading-from-auth0-php-sdk-v7-to-v8/139435.md?page=1)
