@@ -21,7 +21,8 @@ possible.
2121
2222#### Improved Caching
2323
24- * Implement caching in credentials instead of as a wrapper:
24+ * Implements caching in credentials in ` CacheTrait ` instead of using the
25+ ` CredentialsCache ` wrapper:
2526
2627``` php
2728$auth = new GoogleClient();
@@ -31,8 +32,7 @@ $credentials = $auth->makeCredentials([
3132]);
3233```
3334* Implement [ in-memory cache] ( https://github.com/googleapis/google-auth-library-php/tree/master/src/Cache ) by default
34- * Add caching and check expiry for ID tokens
35- * Fix [ SysVCachePool race condition] ( https://github.com/googleapis/google-auth-library-php/issues/226 )
35+ * ** TODO** : Fix [ SysVCachePool race condition] ( https://github.com/googleapis/google-auth-library-php/issues/226 )
3636* ** TODO** : Cache keys
3737 * Ensure different Auth Token types don't overwrite each other (ID tokens vs Access Token)
3838 * Ensure unique cache keys for different credentials / scopes / etc
@@ -47,15 +47,28 @@ $credentials = $auth->makeCredentials([
4747
4848* Provides an abstraction from Guzzle HTTP Client
4949 * Using the composer "[ replace] ( https://stackoverflow.com/questions/18882201/how-does-the-replace-property-work-with-composer ) " keyword, users can ignore sub-dependencies such as Guzzle in favor of a separate HTTP library
50- * Provide documentation on how to use a different library
50+ * ** TODO ** : Provide documentation on how to use a different library
5151* Replaces Middleware classes with ` CredentialsClient ` and ` ApiKeyClient ` classes
52- * See [ Google HTTP PRD] ( https://docs.google.com/document/d/1In1uKSqvrHe5M-KX-sgmuGRC9oWLrqe1wxSbvUESBFc/edit?usp=sharing )
52+ * Adds ` Google\Http\ClientInterface ` and ` Google\Http\PromiseInterface ` for
53+ vendor abstraction.
54+ * Adds ` Google\Http\Client\GuzzleClient ` , ` Google\Http\Promise\GuzzlePromise `
55+ and ` Google\Http\Client\Psr18Client ` implementations.
56+ * Uses ` Guzzle ` implementations by default.
5357
58+ ** Example**
59+
60+ ``` php
61+ $guzzleConfig = [ /* some custom config */ ];
62+ $guzzle = new GuzzleHttp\Client($guzzleConfig);
63+ $httpClient = new Google\Http\Client\GuzzleClient($guzzle);
64+ $auth = new GoogleAuth(['httpClient' => $httpClient]);
65+ ```
5466
5567#### New ` GoogleAuth ` class
5668
5769` GoogleAuth ` replaces ` ApplicationDefaultCredentials ` , and provides a
58- centralized, single entrypoint to the auth library:
70+ centralized, single entrypoint to the auth library. It has the following
71+ methods:
5972
6073``` php
6174namespace Google\Auth;
@@ -72,9 +85,19 @@ class GoogleAuth
7285 public function makeHttpClient(
7386 ClientInterface $http = null
7487 ): ApiKeyClient | CredentialsClient;
88+
89+ public function onCompute(): book;
7590}
7691```
7792
93+ The new ` GoogleAuth ` class does the following:
94+
95+ * Returns Application Default Credentials for the environment.
96+ * Uses options array instead of list of arguments in method signature.
97+ * Consolidates HTTP Handler and Caching options in method signatures in favor
98+ of class constructor config.
99+ * Removes static methods and makes constants private.
100+
78101** Example: Access token auth**
79102
80103``` php
@@ -97,14 +120,6 @@ $authHttp = $auth->makeHttpClient(new Google\Http\Guzzle6Client($guzzle));
97120$response = $authHttp->sendRequest(new Request('GET', '/'));
98121```
99122
100- The new ` GoogleAuth ` class does the following:
101-
102- * Returns Application Default Credentials for the environment
103- * Improved class interface:
104- * Uses options array instead of list of arguments in method signature
105- * Consolidates HTTP Handler / Caching options
106- * Removes static methods
107-
108123** Example: Metadata**
109124
110125``` php
@@ -118,10 +133,9 @@ if ($auth->onCompute()) {
118133// GCECredentials::onGce($httpHandler = null);
119134```
120135
121- #### Improved ` Credentials ` Interface
136+ #### New ` CredentialsInterface ` and ` CredentialsTrait ` to replace ` CredentialsLoader `
122137
123138* Uses options array instead of list of arguments in method signature
124- * ` http ` , ` httpOptions ` , ` cache ` , ` cacheOptions `
125139* Renames ` updateMetadata ` to ` getRequestMetadata `
126140 * An array of headers is returned instead of updating an existing array
127141* Removes ** tokenCallback**
@@ -166,7 +180,7 @@ interface CredentialsInterface
166180}
167181```
168182
169- #### Improved ID Token Auth
183+ #### Improved ID Token auth
170184
171185* The ` AccessToken ` class has been combined with ` OAuth2 ` and ` GoogleAuth `
172186 * ` verify ` functions are in the OAuth2 class
@@ -180,40 +194,41 @@ interface CredentialsInterface
180194** ID token verify**
181195
182196``` php
183- $oauth = new OAuth2 ();
184- $oauth ->verify($idToken);
197+ $googleAuth = new GoogleAuth ();
198+ $googleAuth ->verify($idToken);
185199```
186200
187- ** ID token auth (implicit) **
201+ ** ID token auth**
188202
189203``` php
190204use Google\Auth\GoogleAuth;
191205use Psr\Http\Message\Request;
192206
193207// create auth client
194208$cloudRunUrl = 'https://cloud-run-url';
195- $auth = new GoogleAuth([
209+ $googleAuth = new GoogleAuth([
196210 'targetAudience' => $cloudRunUrl,
197211]);
198212
199213// create an authorized HTTP client and send a request
200214// @throws InvalidArgumentException if credentials do not support ID Token auth
201- $http = $auth ->makeHttpClient();
215+ $http = $googleAuth ->makeHttpClient();
202216$response = $http->send(new Request('GET', $cloudRunUrl));
203217```
204218
205219#### SignBlob Implementation
206220
207- * Fallback to calling [ Service Account Credentials] ( https://cloud.google.com/iam/docs/reference/credentials/rest ) API if ` openssl ` isn't installed
221+ * New ` SignBlobInterface `
222+ * Falls back to calling [ Service Account Credentials] ( https://cloud.google.com/iam/docs/reference/credentials/rest ) API if ` openssl ` isn't installed.
208223
209224#### Improved 3LO Support
210225
211- * Ensure refresh token is used when access token is expired
212- * Add ` OAuthCredentials ` class for wrapping the OAuth2 service
213- * ~~ Add caching to ` OAuth2 ` ~~
214- * ~~ Fix ` OAuth2::isExpired ` to return ` true ` when token expiration is null~~
215- * Add method ` hasValidToken ` ?
216- * add support for ` credentialsFile ` option on ` OAuth2 `
226+ * Ensures refresh token is used when access token is expired
227+ * Adds ` OAuth2Credentials ` class for wrapping the OAuth2 service
228+ * Adds support for ` credentialsFile ` option on ` OAuth2 `
229+ * ` OAuth2::isExpired ` now returns ` true ` when token expiration is null
230+ * ** TODO ** : Add caching to ` OAuth2 `
231+ * ** TODO ** : Consider adding method ` hasValidToken `
217232
218233``` php
219234$oauth = new OAuth2(
0 commit comments