I'm trying to make create an internal data warehouse that collects every one of our user's call data on a nightly basis. My initial attempt took an absurd amount of time as I had to throttle the rate of API calls to avoid rate limits. I contacted dev support and was told I could make multiple API calls without encountering limits by staying authenticated on multiple extensions. I'm not sure how to stay authenticated on multiple extensions in python... using the python ringcentral module requires logging in with a username and pw, is there any way around this?
Thanks so much for your help @Phong Vu. If anyone is interested in an alternative solution, you can generate access tokens for multiple users, store these tokens in a database and use the tokens to make multiple simultaneous calls. That method worked beautifully for me. Hope it helps!
To read all users' call data on a single API call, you can login (authenticate) your app with a super admin user (e.g. the default 101 extension), then read the call log at the account level (see the reference)
Now, if you need to login every time you call an API, you can implement the authentication this way:
from ringcentral import SDK import json from os import path rcsdk = SDK( RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER) platform = rcsdk.platform() def login(): res = platform.login(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD) file = open("access-tokens.json",'w') file.write(res.text()) file.close() read_calllog() def read_calllog(): platform = rcsdk.platform() file = open("access-tokens.json",'r') tokens = file.read() platform.auth().set_data(json.loads(tokens)) if platform.logged_in() == False: print ("token expired. Relogin") login() else: params = { 'dateFrom': "2019-01-01T00:00:00.000Z", 'type': ['Voice'], 'direction': ['Outbound'] } resp = platform.get('/restapi/v1.0/account/~/call-log', params) for record in resp.json().records: print "Call type: " + record.type if path.exists("access-tokens.json"): print("has token") read_calllog() else: print ("must login") login()
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder