I’m trying to refresh my token in my c# application but I get an error 400 with
"{\"error\":\"Bad Request\",\"status\":400,\"message\":\"The parameter \\\"grant_type\\\" was malformed: value must be one of \\\"authorization_code\\\", \\\"password\\\"\"}"
back
The way I am doing the request is the same as getting the first authorization.
The code I’m using:
private bool Reauthorize(string token, out string oicf, out string id)
{
WebRequest request = WebRequest.Create("https://api.twitch.tv/api/oauth2/token");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
byte[] buffer = Encoding.ASCII.GetBytes($"grant_type=refresh_token&client_id=dhpfs0eg1zy0u0dbp3mc90pa3px2dr&refresh_token={token}&client_secret=");
byte[] scrtBuffer = ProtectedData.Unprotect(GetSecret(), new byte[] { 0, 1, 9, 2, 8, 3, 7, 4, 7, 5, 6, 3, 2 }, DataProtectionScope.CurrentUser);
request.ContentLength = buffer.Length + scrtBuffer.Length;
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(buffer, 0, buffer.Length);
requestStream.Write(scrtBuffer, 0, scrtBuffer.Length);
requestStream.Flush();
Array.Clear(scrtBuffer, 0, scrtBuffer.Length);
}
WebResponse response = request.GetResponse();