diff --git a/src/OAuth2Middleware.php b/src/OAuth2Middleware.php index 72e3a39..0670907 100644 --- a/src/OAuth2Middleware.php +++ b/src/OAuth2Middleware.php @@ -83,6 +83,11 @@ private function onFulfilled(RequestInterface $request, array $options, $handler private function onRejected(RequestInterface $request, array $options, $handler) { return function ($reason) use ($request, $options) { + if (class_exists('\GuzzleHttp\Promise\Create')) { + return \GuzzleHttp\Promise\Create::rejectionFor($reason); + } + + // As of Guzzle Promises 2.0.0, the rejection_for function is deprecated and replaced with Create::rejectionFor return \GuzzleHttp\Promise\rejection_for($reason); }; }