RingCentral OAuth 2.0 Grant model.

  • 1
  • Question
  • Updated 2 years ago
Dear Team,

We are using RingCentral SDK in our product. Recently we are implementing OAuth 2.0 grant model for user authentication. Though we are able to successfully logged in using RC OAuth 2.0 Authentication. 

After receiving the access token we need to get user phone number(direct number) which he was used for RC OAuth login. Then only we can use the same number during RingOut (from field).

Is there any way to find out . I have been searching in the RC Document. Since we were able to get only list of phone number's per account using getPhoneNumber Api Call.It contains all the phone number's for the account. 

But we need the phone number which one he was given during RC OAuth login.

Waiting for your response. 

Thanks in advance.

Regards,
Mathikumar.C
Photo of Mathi Kumar

Mathi Kumar

  • 242 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
Photo of John Wang

John Wang, Official Rep

  • 5,654 Points 5k badge 2x thumb
You can retrieve a user's phone numbers by calling the extension phone number endpoint (e.g. "account/~/extension/~/phone-number" which is described below:

https://developer.ringcentral.com/api-docs/latest/index.html#!#RefExtensionPhoneNumbers.html

A RingCentral user has an extension which can have multiple phone numbers. Using the above endpoint, you'll receive only the phone numbers associated with that user.

Since a user can login with any of their phone numbers, e.g. main company number + extension, digital line number, direct number, etc., our best practices is to allow a user to login with any number and after doing so, making available all their numbers for use, e.g. voice calls, SMS, fax, etc.

Let us know if that helps.
(Edited)
Photo of Mathi Kumar

Mathi Kumar

  • 242 Points 100 badge 2x thumb
Dear John Wang,

Greetings!!!

Thanks for your reply.

After successful RingCentral login(after getting access token) I have called above (account/~/extension/~/phone-number) apiCall to get particular phone number which one i was used during OAuth RIngCentral login(1XXXXXXXXXX). 

But i got below response as list of phone numbers. But we need the phone number which was  given during RingCentral OAuth login. Then only we can use the same phone number during ring-out (from field) .

Hope this is clears.

Could you please let me know if any further information is needed. 

 {  "uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/665168005/extension/665168005/phone-nu...;,
  "records" : [ {
    "id" : ZZZZZZZZ,
    "phoneNumber" : "+1XXXXXXXXXX",
    "paymentType" : "Local",
    "location" : "Alamitos, CA",
    "type" : "VoiceFax",
    "usageType" : "MainCompanyNumber",
    "features" : [ "SmsSender", "CallerId" ],
    "status" : "Normal",
    "country" : {
      "uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/country/1";,
      "id" : "1",
      "name" : "United States"
    }
  }, {
    "id" : AAAAAAAA,
    "phoneNumber" : "+1YYYYYYYYYYY",
    "paymentType" : "Local",
    "location" : "Philadelphia, PA",
    "type" : "VoiceFax",
    "usageType" : "DirectNumber",
    "features" : [ "SmsSender", "CallerId" ],
    "status" : "Normal",
    "country" : {
      "uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/country/1";,
      "id" : "1",
      "name" : "United States"
    }
  } ],


Regards,
Mathikumar.C
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,642 Points 5k badge 2x thumb
These are two numbers available for the same user. You can tell by looking at the "usageType" values. In your case, one is the "MainCompanyNumber" (which the user is able to use for dialing) the other is the "DirectNumber" (which the user is also able to use for dialing).

According to your original question, "After receiving the access token we need to get user phone number(direct number) which he was used for RC OAuth login.".

So in this case, you would want to use the phone-number.id where usageType = "DirectNumber". (id AAAAAAA in your example response)

Does this answer your question?
Photo of John Wang

John Wang, Official Rep

  • 5,654 Points 5k badge 2x thumb
Hi Mathi,

A correction is necessary for the above. To select calling phone numbers for RingOut, you must use the "account/~/extension~/forwarding-number" endpoint and filter for phone numbers with the "CallForwarding" feature.

The "account/~/extension~/phone-number" endpoint is used for finding phone numbers that can be used for the Caller ID. Currently, the RingOut API does not support setting the Caller ID value and uses the Caller ID setting set in the Online Account Portal under the "RingOut for Web" feature. To configure a Caller ID via an API call, consider using WebRTC.

Some additional information is available here:

  1. https://developer.ringcentral.com/api-docs/latest/index.html#!#MakeRingOut.html
  2. http://ringcentral-sdk-ruby.readthedocs.io/en/latest/usage/voice/Click-To-Call/

If more than one phone number is available in the account under "forwarding-number" with the "CallForwarding" feature, that means the user can receive calls on more than one number. Best practices is to create a select element and allow the user to choose which number to use.

Thanks,
John
Photo of Mathi Kumar

Mathi Kumar

  • 242 Points 100 badge 2x thumb
Dear John,

Much appreciate for your quick response. 
 
I decided to go in your way to give choice to customer to choose phone number after successful login.

So, For the first select element(RingCentral Phones) i can use "account/~/extension/~/phone-number" endpoint to get Customer's RingCentral phone numbers.

In second select element(Other Phones) i will use "account/~/extension~/forwarding-number"  endpoint to get other phones what customer have in RingCentral Online Portal (Call handling & Forwarding).

According to customer's choice of phone number, we will make "from" field during RingOut process.

Hope this will be a better idea. 

Could you please suggest us if you feel any changes.

Regards,
Mathikumar.C
Photo of John Wang

John Wang, Official Rep

  • 5,476 Points 5k badge 2x thumb
Hi Mathi,

For now you only need 1 select element to map to "account/~/extension/~/forwarding-number" since the RingOut API always works with forwarding numbers. Be sure to include only numbers with "CallForwarding" in the "features" array. Forwarding numbers are configured in the Online Account Portal to forward your calls to.

There's no need to have a select element for "account/~/extension/~/phone-number" as it is used with other API calls.

Thanks,
John
(Edited)
Photo of Mathi Kumar

Mathi Kumar

  • 242 Points 100 badge 2x thumb
Dear John,

Thanks for the suggestion on above.

Could you please do me  a  favour on below conditions. As i already said we are using RingCentral SDK in our product. 

We want to know when we will get below call status if we make outgoing call through Ring Out api.

Status:
Call Status : Cannot Reach
Caller Status :Generic Error
Callee Status :Generic Error

Because lot of RingCentral users are getting above call status when they make call from our product.But when they make call from SoftPhone there is a no issue at all. 

Waiting for your quick response.

Note: We are using SDK version 1.3.0

Thanks & Regards,
Mathikumar.C

 
Photo of Mathi Kumar

Mathi Kumar

  • 242 Points 100 badge 2x thumb
Hi Dean,

Thanks for your response.

As in my  previous comment there is only one direct number for extension id. But for customer there might be a one or more direct number can be mapped to same extension id. So i think  that end point will not work to choose one particular phone number for RIngOut.

We need to give choice to customer to choose which number customer wants to use for RIngOut Process.

Regards,
Mathikumar.C
Photo of VB

VB, Official Rep

  • 1,470 Points 1k badge 2x thumb
Hi Mathikumar,

Could you please create a developer support case (https://developers.ringcentral.com/api/support-cases/create) to help isolate and resolve this issue.
In your support case, please reference the URL for this community post, and inform them that you've been asked to have this issue directly escalated to Tier 2 developer support.