@@ -375,28 +375,28 @@ protected function getRequestTarget(string $uri):string{
375
375
* @inheritDoc
376
376
* @throws \chillerlan\OAuth\Core\InvalidAccessTokenException
377
377
*/
378
- public function sendRequest (RequestInterface $ request ):ResponseInterface {
379
-
380
- // get authorization only if we request the provider API
381
- if (str_starts_with ((string )$ request ->getUri (), $ this ->apiURL )){
382
- $ token = $ this ->storage ->getAccessToken ($ this ->serviceName );
378
+ final public function sendRequest (RequestInterface $ request ):ResponseInterface {
379
+ // get authorization only if we request the provider API,
380
+ // shortcut reroute to the http client otherwise.
381
+ // avoid sending bearer tokens to unknown hosts
382
+ if (!str_starts_with ((string )$ request ->getUri (), $ this ->apiURL )){
383
+ return $ this ->http ->sendRequest ($ request );
384
+ }
383
385
384
- // attempt to refresh an expired token
385
- if ($ token ->isExpired () || $ token ->expires === $ token ::EOL_UNKNOWN ){
386
+ $ token = $ this ->storage ->getAccessToken ($ this ->serviceName );
386
387
387
- if ($ this instanceof TokenRefresh && $ this ->options ->tokenAutoRefresh ){
388
- $ token = $ this ->refreshAccessToken ($ token );
389
- }
390
- else {
391
- throw new InvalidAccessTokenException ;
392
- }
388
+ // attempt to refresh an expired token
389
+ if ($ token ->isExpired ()){
393
390
391
+ if (!$ this instanceof TokenRefresh || $ this ->options ->tokenAutoRefresh !== true ){
392
+ throw new InvalidAccessTokenException ;
394
393
}
395
394
396
- $ request = $ this ->getRequestAuthorization ($ request , $ token );
397
- final public function sendRequest (RequestInterface $ request ):ResponseInterface {
395
+ $ token = $ this ->refreshAccessToken ($ token );
398
396
}
399
397
398
+ $ request = $ this ->getRequestAuthorization ($ request , $ token );
399
+
400
400
return $ this ->http ->sendRequest ($ request );
401
401
}
402
402
0 commit comments