Skip to content

Commit 8f3f7db

Browse files
authored
fixes issue with BC breaking google/auth change (#1028)
* fixes issue with BC breaking google/auth change
1 parent d869778 commit 8f3f7db

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/Google/AuthHandler/Guzzle5AuthHandler.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Google\Auth\CredentialsLoader;
44
use Google\Auth\HttpHandler\HttpHandlerFactory;
5+
use Google\Auth\FetchAuthTokenCache;
56
use Google\Auth\Subscriber\AuthTokenSubscriber;
67
use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
78
use Google\Auth\Subscriber\SimpleSubscriber;
@@ -28,15 +29,21 @@ public function attachCredentials(
2829
CredentialsLoader $credentials,
2930
callable $tokenCallback = null
3031
) {
32+
// use the provided cache
33+
if ($this->cache) {
34+
$credentials = new FetchAuthTokenCache(
35+
$credentials,
36+
$this->cacheConfig,
37+
$this->cache
38+
);
39+
}
3140
// if we end up needing to make an HTTP request to retrieve credentials, we
3241
// can use our existing one, but we need to throw exceptions so the error
3342
// bubbles up.
3443
$authHttp = $this->createAuthHttp($http);
3544
$authHttpHandler = HttpHandlerFactory::build($authHttp);
3645
$subscriber = new AuthTokenSubscriber(
3746
$credentials,
38-
$this->cacheConfig,
39-
$this->cache,
4047
$authHttpHandler,
4148
$tokenCallback
4249
);
@@ -56,7 +63,7 @@ public function attachToken(ClientInterface $http, array $token, array $scopes)
5663
$subscriber = new ScopedAccessTokenSubscriber(
5764
$tokenFunc,
5865
$scopes,
59-
[],
66+
$this->cacheConfig,
6067
$this->cache
6168
);
6269

src/Google/AuthHandler/Guzzle6AuthHandler.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Google\Auth\CredentialsLoader;
44
use Google\Auth\HttpHandler\HttpHandlerFactory;
5+
use Google\Auth\FetchAuthTokenCache;
56
use Google\Auth\Middleware\AuthTokenMiddleware;
67
use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
78
use Google\Auth\Middleware\SimpleMiddleware;
@@ -28,15 +29,21 @@ public function attachCredentials(
2829
CredentialsLoader $credentials,
2930
callable $tokenCallback = null
3031
) {
32+
// use the provided cache
33+
if ($this->cache) {
34+
$credentials = new FetchAuthTokenCache(
35+
$credentials,
36+
$this->cacheConfig,
37+
$this->cache
38+
);
39+
}
3140
// if we end up needing to make an HTTP request to retrieve credentials, we
3241
// can use our existing one, but we need to throw exceptions so the error
3342
// bubbles up.
3443
$authHttp = $this->createAuthHttp($http);
3544
$authHttpHandler = HttpHandlerFactory::build($authHttp);
3645
$middleware = new AuthTokenMiddleware(
3746
$credentials,
38-
$this->cacheConfig,
39-
$this->cache,
4047
$authHttpHandler,
4148
$tokenCallback
4249
);
@@ -59,7 +66,7 @@ public function attachToken(ClientInterface $http, array $token, array $scopes)
5966
$middleware = new ScopedAccessTokenMiddleware(
6067
$tokenFunc,
6168
$scopes,
62-
[],
69+
$this->cacheConfig,
6370
$this->cache
6471
);
6572

0 commit comments

Comments
 (0)