From 0dcc8a4af42dc38a44332dc029030f4e85cab8b2 Mon Sep 17 00:00:00 2001 From: Oleksandr Horbatiuk Date: Thu, 5 Aug 2021 12:57:26 +0300 Subject: [PATCH] Ensure that API response has correct format when getting user E-mail from the access token --- src/oauth/ZohoOAuthClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/oauth/ZohoOAuthClient.php b/src/oauth/ZohoOAuthClient.php index 4cd62131..2b871735 100644 --- a/src/oauth/ZohoOAuthClient.php +++ b/src/oauth/ZohoOAuthClient.php @@ -158,7 +158,7 @@ public function getUserEmailIdFromIAM($accessToken) $connector->addHeadder(ZohoOAuthConstants::AUTHORIZATION, ZohoOAuthConstants::OAUTH_HEADER_PREFIX . $accessToken); $apiResponse = $connector->get(); $jsonResponse = self::processResponse($apiResponse); - if(!array_key_exists("Email", $jsonResponse)){ + if(!is_array($jsonResponse) || !array_key_exists("Email", $jsonResponse)){ throw new ZohoOAuthException("Exception while fetching UserID from access token, Make sure AAAserver.profile.Read scope is included while generating the Grant token " . $jsonResponse); } return $jsonResponse['Email']; @@ -171,4 +171,4 @@ public function processResponse($apiResponse) return $jsonResponse; } -} \ No newline at end of file +}