question

Glenn B. avatar image
Glenn B. asked Glenn B. commented

Password to JWT Migration

We use VBA code that loops through a recordset and sends SMS text messages to customers as appointment reminders. The SMS text messages sent are sent from the RC telephone number of the employee assigned to the customer receiving the SMS. Our existing code (using password auth) in our app has been working flawlessly for a long time.

In our existing app - using Password Auth - our request header is structured like this:

http.Send "grant_type=password" & "&username=" & strRCEmployeeTel & "&password=" & strRCEmployeePwd & "&extension=" & strRCEmployeeExtension

Later in the Password Auth code - we SEND the SMS from the RCEmployeeTel using this code:

http.Send "{" & """to"": [{""phoneNumber"": """ & strCustomerPhone & """}]," & """from"": {""phoneNumber"": """ & strRCEmployeeTel & """}," & """text"": """ & strMsg & """" & "}"

Moving to our JWT Auth app we are working on - our request header is structured like this:

http.Send "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=" & JWToken

Later in the JWT Auth code - when we attempt to SEND the SMS from the RCEmployeeTel using the same code as above:

http.send "{" & """to"": [{""phoneNumber"": """ & strCustomerPhone & """}]," & """from"": {""phoneNumber"": """ & strRCEmployeeTel & """}," & """text"": """ & strMsg & """" & "}"

We get this error:

{
  "errorCode" : "FeatureNotAvailable",
  "message" : "Phone number doesn't belong to extension",
  "errors" : [ {
    "errorCode" : "MSG-304",
    "message" : "Phone number doesn't belong to extension"
  } ]
}

We thought that the JWT would allow us to send SMS from any of our employee RC telephone numbers - but clearly that is not the case.

Can anyone suggest how we can address the above error?

errors
1 |3000

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

1 Answer

Phong Vu avatar image
Phong Vu answered Glenn B. commented

Use the username and password of the employee who owns the phone number (the one you authenticated the app before), to login the RingCentral Dev portal and generate a JWT token for that employee, then use the JWT to authenticate your app.

JWT is just a replacement for using the username and password of a user. So it must be per user and can be used to authenticate just that user.

2 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.

Glenn B. avatar image Glenn B. commented ·

Thank you Phong! Will set this up and do some testing.

0 Likes 0 ·
Glenn B. avatar image Glenn B. commented ·

Implemented - tested - works perfectly. Thank you again!

0 Likes 0 ·

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