Skip to content
Snippets Groups Projects

Fix Issue #3226792: Catch exception when trying to revoke client access

Open Johannes Haseitl requested to merge issue/google_api_client-3226792:8.x-4.x into 8.x-4.x
1 file
+ 11
2
Compare changes
  • Side-by-side
  • Inline
@@ -47,8 +47,17 @@ class GoogleApiClientRevokeForm extends ContentEntityConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$google_api_client = $this->entity;
$service = \Drupal::service('google_api_client.client');
$service->setGoogleApiClient($google_api_client);
$service->googleClient->revokeToken();
try {
$service->setGoogleApiClient($google_api_client);
$service->googleClient->revokeToken();
}
catch (\Exception $e) {
// In case the google client throws an exception, for example due to an
// expired token, we do not want to break the revoke form, as we will
// reset access token and authenticated anyways.
}
$google_api_client->setAccessToken('');
$google_api_client->setAuthenticated(FALSE);
$google_api_client->save();
Loading