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
Unauthorized Grant Type - Pull Call Log API w/ Python
Tags: call logs
Dec 5, 2022 at 12:45pm   •   1 replies  •  0 likes
Joshua Noble

I'm attempting to pull data from a Sandbox Env - Call Log. There is confirmed one record on the Call Log, for context. I'm using a Sandbox App that uses JWT Auth. When I run 'python3 pray.py' in Terminal, I get the following error:

Unable to authenticate to platform. Check credentials.Unauthorized for this grant type

Here is the code I'm running:

from ringcentral import SDK
 
RINGCENTRAL_CLIENTID = 'hTTB9Rt9QT6ctmCyK9c2EA'
RINGCENTRAL_CLIENTSECRET = 'sP8##############################PG4Qg'
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'
 
rcsdk = SDK( RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER)
platform = rcsdk.platform()
 
JWT_TOKEN = "eyJraWQiOiI########################################MjU2In0"
 
try:
    platform.login( jwt=JWT_TOKEN )
    params = {
        'dateFrom': "2012-01-01T00:00:00.000Z"
        }
    resp = platform.get('/restapi/v1.0/account/~/extension/~/call-log', params)
    for record in resp.json().records:
        print ("Call type: " + record.type)
except Exception as e:
    print ("Unable to authenticate to platform. Check credentials." + str(e))

I have given the Sandbox App every single permission available, including Read Call Log. My Python3 version is Python 3.8.9.

What could be causing this issue? I appreciate any help that can be provided. I scoured other similar questions on the forum, but I was unable to fix with those resolutions.

1 Answer
answered on Dec 5, 2022 at 2:04pm  

Nothing is wrong with the code. And the error is about authentication so app permission is not an issue here.

I check your app and look at the JWT token from your dev portal and I am not sure if you copy the right one. I see the valid one you cerated today in the dev portal is ending with different chars as what you shorten and showed above. This is what I see from your dev portal. Can you double check it.

JWT = "eyJraWQ######################################zelzQ"

 0
on Dec 5, 2022 at 2:45pm   •  0 likes

Ah! I thought it was the JWT from the App itself. Didn't realize I was using the User JWT. This worked. Thank you!



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