For some reason, I get a broken access_token in return when I’m trying to make a user authentication through my .net code.
Strangely, the exact same call in POSTMAN works like a charm.
In essence, the broken access_token returned contains 3 dots like ‘…’ somewhere in token rendering it invalid (verified through jwt.io).
Note, that the json has not been truncated since it actually looks complete.
And the HttpStatusCode == OK
The c# code looks like this:
Dictionary<string, string>? dict = new() {
{ "audience", audience },
{ "grant_type", "password" },
{ "username", username },
{ "password", password },
{ "client_id", clientId },
{ "client_secret", clientSecret }
};
string payload = JsonConvert.SerializeObject(dict);
HttpRequestMessage? req = new(HttpMethod.Post, url) { Content = new StringContent(payload, Encoding.UTF8, "application/json")};
HttpResponseMessage? res = await _httpClient.SendAsync(req);
string result = await res.Content.ReadAsStringAsync();
return new (result, res.IsSuccessStatusCode );
The Postman call looks like this:
POST {myurl}
Content-Type: application/json
{
"client_id": "{my client_id},
"client_secret": "{my_client_secret}",
"audience": "{my_audience_in_api},
"username": "{my_username}",
"password": "{my_password}",
"grant_type": "password"
}