Currently I'm developing getting data via AnalyticsApi which authorized with access token.
I've enabled the feature for access token, but it expires after 2 days.
How can I implement python codes to refresh the Access Token when it becomes expired?
Appreciate if there's any sample python codes.
If you are using the Authorization Code Grant then you can use the following instructions to have the access token automatically refreshed.
If you are using any other authentication method then you'll have to implement your own logic to request a new access token when or before the access token expires.
auth_token_info = apiclient.get_code_authorization_token(os.environ['GENESYS_CLOUD_CODEAUTH_CLIENT_ID'],
os.environ['GENESYS_CLOUD_CODEAUTH_CLIENT_SECRET'],
auth_code,
"https://redirect-uri.com/oauth/callback")
Do you know how to configure redirect_uri?
Do I need to create another http server for it?
This article provides instruction on using Code Authorization. Although if you're just creating a script to call the analytics API then you do not need a user context and Client Credentials would be enough.
apiclient = PureCloudPlatformClientV2.api_client.ApiClient().get_client_credentials_token(os.environ['GENESYS_CLOUD_CLIENT_ID'],
os.environ['GENESYS_CLOUD_CLIENT_SECRET'])
authApi = PureCloudPlatformClientV2.AuthorizationApi(apiclient)
print(authApi.get_authorization_permissions())
Do you mean this one?
Last time i raised another topic that if getting analytics data , access token is necessary.(not only [Client Credentials]).
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.