Skip to content

Commit

Permalink
Change exceptions used to catch failed GCE authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
mxr576 authored Dec 14, 2023
1 parent a882b50 commit 7577a3f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/HttpClient/Plugin/Authentication/GceServiceAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
use Apigee\Edge\Client;
use Apigee\Edge\ClientInterface;
use Apigee\Edge\Exception\ApigeeOnGcpOauth2AuthenticationException;
use Http\Client\Exception;
use Http\Message\Authentication\Header;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\NetworkExceptionInterface;

/**
* GCE Service Account authentication plugin for authenticating to Google
Expand Down Expand Up @@ -61,7 +62,7 @@ public function isAvailable(): bool
$this->authClient()->get('');

return true;
} catch (Exception $e) {
} catch (NetworkExceptionInterface $e) {
return false;
}
}
Expand All @@ -85,7 +86,7 @@ protected function getAccessToken(): void
$response = $this->authClient()->get('');
$decoded_token = json_decode((string) $response->getBody(), true);
$this->tokenStorage->saveToken($decoded_token);
} catch (Exception $e) {
} catch (ClientExceptionInterface $e) {
throw new ApigeeOnGcpOauth2AuthenticationException($e->getMessage(), $e->getCode(), $e);
}
}
Expand Down

0 comments on commit 7577a3f

Please sign in to comment.