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
JWT Token Failure
Tags: authentication
Apr 8, 2022 at 2:45pm   •   2 replies  •  0 likes
Fausto Chepil

creating a private app that has no user interface, only server to Ring Central interface.

I tried this code snippet with the JWT Token created in my Sandbox with clientid and client-secret. I get the following error:

Unable to authenticate to platform. Check credentials.Either code, or username with password, or jwt has to be provided

CODE testest in python:

from ringcentral import SDK
import os,sys

rcsdk = SDK( os.environ.get('RC_CLIENT_ID'),
os.environ.get('RC_CLIENT_SECRET'),
os.environ.get('RC_SERVER_URL') )
platform = rcsdk.platform()

try:
    platform.login( jwt=os.environ.get('RC_JWT') )
except Exception as e:
    print(e)
    sys.exit("Unable to authenticate to platform. Check credentials." + str(e))

print(f'Login with JWT successful.')



My app works fine with a user login and password, which is not practical for distribution or as secure as a JWT.

2 Answers
answered on Apr 8, 2022 at 3:31pm  

Hi @Fausto Chepil here is a sample project on GitHub that you can clone/download and run it. Just make sure to update the .env file with your credentials including JWT and it should work. The code is in Nodejs, if you need help with Python specifically let us know but with this app you can make sure your credentials and settings are all correct.


 1
on Apr 9, 2022 at 9:19am   •  0 likes

Thank you Suyash.

answered on Apr 8, 2022 at 3:08pm  

My guess is that you forgot to update the RingCentral Python SDK. Please double check to reinstall.

https://github.com/ringcentral/ringcentral-python

This code works perfectly for me

from ringcentral import SD

RINGCENTRAL_CLIENTID = ''
RINGCENTRAL_CLIENTSECRET = ''
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'

rcsdk = SDK( RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER)
platform = rcsdk.platform()

JWT_TOKEN = "jwt-token"

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

 2
on Apr 9, 2022 at 9:00am   •  1 likes

Ringcentral was up to date, but its dependencies were not:

pubnub

requests

Thanks again!

on Apr 9, 2022 at 8:36am   •  1 likes

Thank you again Phong!

I should have you on speed dial :)



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