I have set up my function when it is hit, to check if the current access token has expired (from cache). If the access token has expired, I use the refresh token to request a new access token. I am however running into an issue here when I try to hit the “oauth/token” url, getting an unauthorized error: “The remote server returned an error: (401) Unauthorized.”. The request body, method and content type are set up correctly following the Refresh Tokens guidelines
Since the content type is x-www-form-urlencoded, there shouldn’t be any JSON format involved. You’re creating a JSON string which you then serialize. That doesn’t look right, and seems to be the problem.
Not too familiar with C# or the HttpWebRequest class in particular, but check the C# code example on Refresh Tokens, and how the parameters are set there:
@mathiasconradt Ow, my bad! Must have tunnel visioned when I was going through it, I changed the format as suggested and everything works as expected now, thank you!