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()
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!