Can someone please help me writing a simple python script to get the oauth token using api.
,
need some help in writing a simple python code to retrieve oauth token
I don't know what you want to refer to. That code is the RingCentral Python SDK, which helps developers easier to login RingCentral platform. It can be used to login with password flow or OAuth authorization.
To be honest, I don't know what you want to do as your original question is about how to retrieve auth token.
After you log in either ways, you will get the access tokens. And this sample code helps you to achieve the tokens via OAuth. Your problem is you don't know Flask so you cannot use the code as such. But it should help with the basic steps.
https://developers.ringcentral.com/guide/authentication/quick-start#python
@app.route('/oauth2callback', methods=['GET']) def oauth2callback(): platform = rcsdk.platform() auth_code = request.values.get('code') platform.login('', '', '', auth_code, RINGCENTRAL_REDIRECT_URL) tokens = platform.auth().data() session['sessionAccessToken'] = tokens return render_template('test.html')
Is there a example without using the sdk
because when i use SDK i keep getting this error
ImportError: cannot import name 'SDK' from partially initialized module 'ringcentral' (most likely due to a circular import)
That is the tutorial is about "Access RingCentral platform services using Python native API."
Will the app password work in this scenario?
It depends on the account SSO settings. Most of the cases is that it'll not support password flow after enabling SSO.
Implement 3-legged authentication login requires you writing lots of codes. That is why I recommend you to use the SDK. Your problem is your environment and I don't know how you set/install the RingCentral Python SDK. you should solve that problem or then look at the source code of the SDK to implement your own. https://github.com/ringcentral/ringcentral-python
so just a question for 3 legged autorization. What does this
auth_code = request.values.get('code') suppose to return. Ad what if we are not using flask. What will it be equivalent of lets say if we are using requests library
3-legged authorization is just another way to say OAuth 2.0. Search the term to learn more about it if you don't know.
Flask is just a Python Web framework. You can use Django, Web2py or whatever framework you like. It is not a requirement.
How to create a api key. That i can use as auth token?
We don't use API key. We use app client id and client secret instead. You use the client id and secret with the user login credentials (username and password) to get an access token and use the access token to call the platform APIs.
But i don't have password as our account is sso enabled. So how should i will get access token.
That was why I told you about 3-legged authorization. We have an intention to support API key but it is an upcoming feature.
Yeah but in 3 legged authorization you have to spin up an server. is that correct or is there any other way around and also what is this code that is being referred here in the GitHub.
https://github.com/ringcentral/ringcentral-python/blob/758084a2e602efcb0f23f5369f827ea8389be58f/ringcentral/platform/platform.py#L98
And also what is the code that is being reffered here in the github
https://github.com/ringcentral/ringcentral-python/blob/758084a2e602efcb0f23f5369f827ea8389be58f/ringcentral/platform/platform.py#L98
So the thing with native api example is that it needs 'password': os.getenv("RC_PASSWORD")
but we have enabled sso on our account so how will that work?
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