Skip to main content

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
 

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.


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!


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