skothamachu | 2023-12-04 01:24:02 UTC | #1
I am facing an Invalid login credentials issue when i am trying to get the data from the PureCloudPlatformClientV2 sdk. The credential works fine when I run the run for the regions individually ,but fails when I try to run them in a loop ( The first region in the loop works, the rest of them fail). I believe this is happing due to config getting saved in the cache. I tried to do the reimport of library but that didn't help. Is there way to clear the cache ?
Here is what happening when running in loop -
Here is the code -
i def getdialerqueue(region,pureCloudAPI,clientID,clientSecret,DbConnStr):
Reloading the Genesys Module
importlib.reload(PureCloudPlatformClientV2)
tablename ='StagingDialerQueues' PureCloudPlatformClientV2.configuration.host = pureCloudAPI logging.info(PureCloudPlatformClientV2.configuration.host) apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken( clientid=clientID ,client_secret=clientSecret)
PureCloudPlatformClientV2.configuration.accesstoken = apiclient.accesstoken logging.info("Recevied Access Token")
try: page_exists = True page = 1
truncate table
GC.exesqlstatment(dbconnString= DbConnStr,sqlstatement= 'Truncate table StagingDialerQueues')
create an instance of the API class
api_instance = PureCloudPlatformClientV2.RoutingApi()
while (page_exists):
apiresponse = apiinstance.getroutingqueues(pagesize=100, pagenumber = page) jsonresponse = json.loads((apiresponse.tojson())) loadtoDB(region=region,DbConnStr=DbConnStr,tablename =tablename,data=jsonresponse)
if jsonresponse['pagecount'] > 0 and (jsonresponse['pagenumber'] < jsonresponse['pagecount']) : page = page + 1 page_exists = False
else: page_exists = False
except ApiException as e: logging.error("Exception when calling RoutingApi->getroutingqueues: %s\n" % e)
skothamachu | 2023-12-04 01:27:22 UTC | #2
It works when i try to run the Region individually
Just an FYI. I am not looking to run multiple instance of the code on multiple azure function instances for multiple region. Looking to run multiple region on a same infrastructure instance without getting this issue
Jerome.Saint-Marc | 2023-12-04 09:50:23 UTC | #3
Hello,
Can you try with: api_instance = PureCloudPlatformClientV2.RoutingApi(apiclient) ? Also, I don't think that the following is necessary (access token is set on the apiClient inside the get_clientcredentialstoken method): # PureCloudPlatformClientV2.configuration.access_token = apiclient.access_token
Regards,
system | 2024-01-04 09:54:42 UTC | #5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 23474