@@ -124,7 +124,7 @@ public function testRetries(): void
124124 'request ' => [
125125 'uri ' => 'https://www.googleapis.com/auth/invalid-scope ' ,
126126 'headers ' => [
127- 'User-Agent ' => ['GuzzleHttp/6.5.5 curl/7.74.0 PHP/7.4.30 ' ],
127+ 'User-Agent ' => ['GuzzleHttp/6.5.5 curl/7.74.0 PHP/7.4.33 ' ],
128128 'Host ' => ['www.googleapis.com ' ],
129129 'Accept ' => ['application/json ' ],
130130 'Authorization ' => '***** ' ,
@@ -150,6 +150,32 @@ public function testRetries(): void
150150 }
151151 }
152152
153+ public function testDoNotRetryOnWrongCredentials (): void
154+ {
155+ $ testHandler = new TestHandler ();
156+ $ logger = new Logger ('Google Rest API tests ' );
157+ $ logger ->pushHandler ($ testHandler );
158+ $ api = new RestApi (
159+ $ this ->getEnv ('CLIENT_ID ' ),
160+ $ this ->getEnv ('CLIENT_SECRET ' ) . 'invalid ' ,
161+ '' ,
162+ $ this ->getEnv ('REFRESH_TOKEN ' ),
163+ $ logger
164+ );
165+
166+ try {
167+ $ api ->request ('/oauth2/v3/userinfo ' );
168+ } catch (ClientException $ e ) {
169+ $ this ->assertStringContainsString ('401 Unauthorized ' , $ e ->getMessage ());
170+ }
171+
172+ $ this ->assertCount (1 , $ testHandler ->getRecords ());
173+ $ this ->assertStringContainsString (
174+ 'Retrying request (0x) - reason: Unauthorized ' ,
175+ $ testHandler ->getRecords ()[0 ]['message ' ]
176+ );
177+ }
178+
153179 protected function getEnv (string $ name ): string
154180 {
155181 $ value = getenv ($ name );
0 commit comments