I am new to the Oauth2 concept. I am trying to connect to API. The API requires me to get a token code with client credentials. I am using the library RestSharp to connect. I am using the code below and getting the following error:
Cannot send a content-body with this verb-type.
Below is my code:
Dim Url As String = "https://api.site.com:21443/api/auth"Dim client_id As String = "ID"Dim client_secret As String = "SECRET"Dim rClient As New RestClient(Url)Dim rRequest As New RestRequest(Method.Post)rRequest.AddHeader("content-type", "application/json")rRequest.AddParameter("client_id", client_id)rRequest.AddParameter("client_secret", client_secret)rRequest.AddParameter("grant_type", "client_credentials")ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12Dim tResponse As RestResponse = rClient.Execute(rRequest)Dim responseJson As String = tResponse.Content
I code above is something I found on the web. I obviously do not understand, but I do need some help. How can I get the token using client credentials grant type.