News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
staying authenticated on multiple extensions in python to avoid rate limits
Tags: authentication
Oct 11, 2019 at 12:17pm   •   2 replies  •  0 likes
Sugam Manocha

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?

2 Answers
answered on Dec 3, 2019 at 12:12pm  

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!


 1
answered on Oct 11, 2019 at 1:48pm  

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



 0



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

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us