Skip to content

Commit 5658154

Browse files
committed
Exception will be thrown if response doesn't contain 'Email' key for
User info url using grant token
1 parent 63690f4 commit 5658154

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/oauth/ZohoOAuthClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ public function getUserEmailIdFromIAM($accessToken)
158158
$connector->addHeadder(ZohoOAuthConstants::AUTHORIZATION, ZohoOAuthConstants::OAUTH_HEADER_PREFIX . $accessToken);
159159
$apiResponse = $connector->get();
160160
$jsonResponse = self::processResponse($apiResponse);
161-
161+
if(!array_key_exists("Email", $jsonResponse)){
162+
throw new ZohoOAuthException("Exception while fetching UserID from grant token, Make sure AAAserver.profile.Read scope is included while generating the Grant token " . $jsonResponse);
163+
}
162164
return $jsonResponse['Email'];
163165
}
164166

0 commit comments

Comments
 (0)