OAuth authentication using password with special characters fails

Hello Community,

we have encountered an issue, where if a user has password with special character %, followed by 2 numbers, the OAuth request will fail with 403, even though the password is in fact valid. This is probably due to URL encoding during the request.

Correct password: 6QsTrk7%R
Incorrect password: 6QsTrk7%12R

I am using this C# code with grant type password https://community.telligent.com/community/11/w/developer-training/63121/authentication#mcetoc_1eeqvi5bt4

var tokenRequest = WebRequest.Create($"{baseUrl}/api.ashx/v2/oauth/token") as HttpWebRequest;

var data = string.Format("client_id={0}&grant_type=password&username={1}&password={2}", clientId, username, password);
byte[] bytes = Encoding.UTF8.GetBytes(data);

tokenRequest.ContentType = "application/x-www-form-urlencoded";
tokenRequest.ContentLength = bytes.Length;
tokenRequest.Method = "Post";

var requestStream = tokenRequest.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();

string tokenResponse = null;
using (var webTokenResponse = tokenRequest.GetResponse() as HttpWebResponse)
{
    using (var reader = new StreamReader(webTokenResponse.GetResponseStream()))
    {
        tokenResponse = reader.ReadToEnd();
    }
}

Thank you for any advice.