Traceback (most recent call last):
File "C:/PythonCode/purecloud/purecolud1.py", line 20, in
apiClient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(os.environ['abf46b13-febc-4345-af9d-fdd61afrd536'], os.environ['HANDLE CLIENT SECRETS LIKE PASSWORDS'])
File "C:\Python\lib\os.py", line 678, in getitem
raise KeyError(key) from None
KeyError: 'abf46b13-febc-4345-af9d-fdd61afrd536'
Please regenerate your client secret immediately. By posting it publicly on the forum, you have compromised your org.
os.environ[""] is python's way of retrieving environment variables. PURECLOUD_CLIENT_ID and PURECLOUD_CLIENT_SECRET are the names of those variables. You should either set those environment variables so they're available to the application or hardcode them into your application.
I did not shared the original keys out here , they are dummy keys.
As suggested by you I will set the PURECLOUD_CLIENT_ID and PURECLOUD_CLIENT_SECRET variables first and will pass them to os.environ[" "] hope this will work.
We tried to make a role by selecting "Developer" as role and utilized those keys. However we got the same error as posted above. Can you please suggest where we are getting it wrong.
If you're getting this same error, you haven't updated your code to either hardcode the client ID and secret or pull it from the named environment variables. You'll have to update this line of code to get different behavior. If you've updated your code and that that's not literally the error you're getting anymore, please share the new error.
I have replaced the entire os.environ['xxx'] and it responded with exception about authorization issue. What sort of authorization is needed? The provided client id and token have give developer role.
The Developer role just gives you access to read/write access to OAuth clients.
You want to at least add the 'Engage Supervisor' or it might be called 'PureCloud Supervisor' role in your Client Credentials. If in doubt, you can add the 'Master Admin' to gain access to almost all API. Needless to say, you may want to identify and use stricter roles in production as best practice.
Thanks the sample code started responding with data, now we are looking for our historical records from the new application, can we get the old data from here?