Skip to main content
Question

Need info to send SMS text from a .NET windows application

  • September 27, 2024
  • 3 replies
  • 39 views

Forum|alt.badge.img

We were using Ring Central last year but the service was terminated.  We just re-started the service and I would like to use the existing code to access our new account.

Below is the code to get an SMS Token.  We were using the phone number as the Username.  Where can I get the “Authorization” code, username and password to get a “Token”?

Thanks!

 

 Public Shared Function GetSmsToken() As String
     Dim client = New RestClient("https://platform.ringcentral.com/restapi/oauth/token")
     'client.Timeout = -1

     Dim request = New RestRequest(Method.Post)
     '  request.Timeout = -1
     request.AddHeader("Authorization", "Basic R3hGUlk3S05RSmFUeTlMU19nbjR1dzp4alNlY3Y2alJHaVo2Ul9YTzdmUnVRUW5weXVlY0xUUk8xcDlTTUhuZGc0QQ==")
     request.AddHeader("Content-Type", "application/x-www-form-urlencoded")
     request.AddParameter("grant_type", "password")
     request.AddParameter("username", userName)
     request.AddParameter("password", "xxxxx")
     request.AddParameter("extension", "101")
     Dim response As RestResponse = client.Execute(request)
     Console.WriteLine(response.Content)
     Dim jobj = JObject.Parse(response.Content)

     If Not jobj.ContainsKey("access_token") Then
         Throw New Exception($"Access token not found in response. Body:\r\n{response.Content}")
     End If

     Return jobj("access_token").ToObject(Of String)()
 End Function
 

3 replies

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • 2331 replies
  • September 27, 2024

We no longer support password flow authentication.

Please read this post about the changes and how to obtain a JWT token for authentication.

Also check out the dev guide for more details.


Forum|alt.badge.img
  • Author
  • New Participant
  • 1 reply
  • September 27, 2024

Our existing application is written in VB.net using .NET framework 4.8, NOT Core.

Will this matter?

And do you have sample code in VB.NET?

Thanks!


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • 2331 replies
  • September 27, 2024
rgrados wrote:

Our existing application is written in VB.net using .NET framework 4.8, NOT Core.

Will this matter?

And do you have sample code in VB.NET?

Thanks!

I don’t have any sample code nor I am a VB.NET developer. But I guess you can modify the existing code like this.

 # Old code
 request.AddHeader("Content-Type", "application/x-www-form-urlencoded")

 request.AddParameter("grant_type", "password")
 request.AddParameter("username", userName)
 request.AddParameter("password", "xxxxx")
 request.AddParameter("extension", "101")

# New code
 request.AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
 request.AddParameter("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer")
 request.AddParameter("assertion", userJWT)

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings