From c7c836e2483f3a52349b496f1bb700aabfea9e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20THIVOLLE-CAZAT?= Date: Thu, 12 Dec 2019 18:51:09 +0100 Subject: [PATCH] raise exception when INVALID_OAUTHSCOPE error is answered by API --- zcrmsdk/OAuthClient.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zcrmsdk/OAuthClient.py b/zcrmsdk/OAuthClient.py index 0c18623..ee9c635 100644 --- a/zcrmsdk/OAuthClient.py +++ b/zcrmsdk/OAuthClient.py @@ -210,7 +210,13 @@ def get_user_email_from_iam(self,accessToken): header={ZohoOAuthConstants.AUTHORIZATION:(ZohoOAuthConstants.OAUTH_HEADER_PREFIX+accessToken)} connector=ZohoOAuthHTTPConnector.get_instance(ZohoOAuth.get_user_info_url(),None,header,None,ZohoOAuthConstants.REQUEST_METHOD_GET) response=connector.trigger_request() - return response.json()['Email'] + data = response.json() + if data.get('response') == 'error': + raise ZohoOAuthException(( + "Exception occured while fetching email from iam ; " + "Response is: {0}" + ).format(data)) + return data['Email'] class ZohoOAuthTokens(object): '''