zcrm-python-sdk icon indicating copy to clipboard operation
zcrm-python-sdk copied to clipboard

raise exception when INVALID_OAUTHSCOPE error is answered by API

Open thivolle-cazat-cedric opened this issue 5 years ago • 0 comments

On my first try i had following exception:

  File "test.py", line 18, in <module>
    oauth_token = client.generate_access_token(grand_token)
  File "***Developpement/environements/**zohotest/lib/python2.7/site-packages/zcrmsdk/OAuthClient.py", line 182, in generate_access_token
    oAuthTokens.set_user_email(self.get_user_email_from_iam(oAuthTokens.accessToken))
  File "***Developpement/environements/**zohotest/lib/python2.7/site-packages/zcrmsdk/OAuthClient.py", line 213, in get_user_email_from_iam
    return response.json()['Email']
KeyError: 'Email'

Due to an INVALID_OAUTHSCOPE error when we want to set email from who iam endpoint.

the test.py file:

import zcrmsdk

cfg = {
'sandbox': "False",
'applicationLogFilePath': './log',
'client_id':'1000.***',
'client_secret':'***',
'redirect_uri':'http://127.0.0.1:8080/cb',
'accounts_url':'https://accounts.zoho.com',
'token_persistence_path':'./',
'access_type':'online',
'currentUserEmail':'***@***',
'apiVersion':'v2',
}
# scope=ZohoCRM.modules.ALL

zcrmsdk.ZCRMRestClient.initialize(cfg)
grand_token = "1000.*****"
client = zcrmsdk.ZohoOAuth.get_client_instance()
oauth_token = client.generate_access_token(grand_token)
print(oauth_token)

I get this issue with a "Self client" with scope : ZohoCRM.modules.ALL

thivolle-cazat-cedric avatar Dec 12 '19 19:12 thivolle-cazat-cedric