question

Anish Rege avatar image
Anish Rege asked Anish Rege edited

Making API Ringout calls using different users

We have an app in Production mode which uses MakeACall endpoint to make RingOut calls. Currently we are using the JWT auth flow. What's happening is all the calls which are going out are through the JWT user who created the app, and we are getting a message "Request rate exceeded" . What we want to do instead is, calls should happen based on the user who is trying to make the call and not based on the user who create the App. We are not sure how to do that and create users for each of the "from" caller. Is there a way to achieve this?


we tried using ringout url with extId as follows but it didnt help:
https://platform.ringcentral.com/restapi/v1.0/account/~/extension/{extId}/ring-out

Also, if there is any other solution you recommend instead of ours, we would like to know.


ringout
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

There are 2 options

1/ You collect the JWT of each user and when that user loads the page, use his JWT token to get the access token and make a ring-out call.

2/ Implement 3-legged authorization so that it requires a user to login with their own RingCentral username/password. Once the user logged in, you get the access token and use it to call the ring-out API.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Anish Rege avatar image
Anish Rege answered Phong Vu commented

It would be helpful if you could provide us a working example(maybe a github link to project) for "Implementing 3-legged authorization". That would be much helpful in addition to api docs.

3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·
0 Likes 0 ·
Anish Rege avatar image Anish Rege Phong Vu ♦♦ commented ·

Thank you, for the 1st implementation you recommended to get JWT for each user, I believe we have to do a username/password based auth to get the token for the respective user?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Anish Rege commented ·

No, password flow is deprecated and we will only support JWT. For JWT, there is no API to generate a JWT token for a user. So each user must login their RingCentral developer portal to create its own JWT and provide you with the JWT token. Or it's up to you how you will get the JWT token from your users. Once you have their JWT token, you use it to exchange for the access token to call APIs.

0 Likes 0 ·
Anish Rege avatar image
Anish Rege answered Anish Rege edited

Ok, I tried the authorization code flow (Authorization code flow (ringcentral.com) and the callback successfully happens to the redirect_uri mentioned below after sign in on the ringCentral portal

https://platform.ringcentral.com/restapi/oauth/authorize?response_type=code&redirect_uri=http://localhost:53891/api/RingCentral/GetRingCentralCallback&prompt=login&client_id={clientId}&state=Create


Once we get the code at the callback url mentioned above, when we post to /restapi/oauth/token with post data, it seems to fail with the following response:

{ "error" : "invalid_client", "errors" : [ { "errorCode" : "OAU-153", "message" : "Invalid client: {clienId}", "parameters" : [ { "parameterName" : "client_id", "parameterValue" : "{clientId}" } ] } ], "error_description" : "Invalid client: {clientId}" }

I am using the same ClientId which is been passed to /restapi/oauth/authorize endpoint.


Below is the C# code for retrieving the token

string postData = "grant_type=authorization_code&code=" + code + "&client_id=" + rcOAuthClientId;

var rcAuthKey = CommanFunction.StrEncrypt(rcOAuthClientId + ":" + rcOAuthClientSecret);

var header = new WebHeaderCollection();

header.Add("Authorization", $"Basic {rcAuthKey}");

header.Add("ContentType", "application/x-www-form-urlencoded");

var result = HttpReqCall.Request(WebRequestMethods.Http.Post, rcAuthUrl, postData, header, "application/x-www-form-urlencoded");


Is this anything wrong which i am doing?








1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys