0
votes

I am trying to send oauth request to receive a token and no matter what I do I get an error that nonce was already used. So I decided to send that same request using Fiddler and everything worked flawlessly. The only issue I see is with the request body. I have to send grant_type=client_credentials in the body and it must be of application/x-www-form-urlencoded type. not Json nor XML. RestSharp describes adding JsonBody and XMLbody but both of those would set incorrect content type to the request. In my code I am trying to add the body the following way:

req.AddParameter("grant_type", "client_credentials", ParameterType.RequestBody)

Is that the correct way to add request body? I am also open to all suggestions to what else might be causing that error

Thank you

1

1 Answers

0
votes

For OAuth, to generate a token the grant_type, code, client_secret etc. should be sent as an query parameters. In RestSharp it is done as request.AddQueryParameter("grant_type", "client_credentials")

Everything in detail about OAuth is here