C# Get Channel Informations by Oauth - error 401

Hi,

I’m having trouble getting the channel informations from an oauth token.

I managed getting the oauth with this scopes : user_read+chat:read+channel_read

In the Reference | Twitch Developers documentation it says i need “channel_read” scope so it should be ok.

My code is :
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.twitch.tv/kraken/channel"))
{
request.Headers.Add("Accept", "application/vnd.twitchtv.v5+json");
request.Headers.Add("Client-ID", Properties.Settings.Default.ClientID);
request.Headers.Add("Authorization", $"Oauth {Properties.Settings.Default.Token}");
var response = await httpClient.SendAsync(request);
Console.WriteLine(response);
} }`

And i’m getting a Unauthorized response that i don’t get :

StatusCode: 401, ReasonPhrase: ‘Unauthorized’, Version: 1.1, Content:
System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
Access-Control-Allow-Origin: *
Pragma: no-cache
Timing-Allow-Origin: https://www.twitch.tv
X-Served-By: cache-sea4480-SEA, cache-cdg20771-CDG
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1591969132.349644,VS0,VS0,VE147
Vary: Accept-Encoding
Strict-Transport-Security: max-age=300
Cache-Control: no-store, must-revalidate, no-cache, private
Date: Fri, 12 Jun 2020 13:38:52 GMT
Content-Length: 71
Content-Type: application/json; charset=utf-8
Expires: 0
}

If anyone can tell me what i missed it would be a pleasure :slight_smile:

Thanks !

Shakawah

should be

request.Headers.Add("Authorization", $"OAuth {Properties.Settings.Default.Token}");
1 Like

You answered so fast !!

Of course it was a case mistake :man_facepalming: :man_facepalming: :man_facepalming:

Thank you !! \o/

1 Like

:smiley:

The header “key” case doesn’t matter but the header “value” case does matter

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.