I'm trying to make a connection to a Github API endpoint using basic authentication. And no matter what I do, I'm getting 403 status as an answer. Has anyone ever experienced this ?
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Clear();
var basicAuthentication = Encoding.ASCII.GetBytes($"{_username}:{_password}");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(basicAuthentication));
var result = await client.GetAsync("https://api.github.com/user");
var content = await result.Content.ReadAsStringAsync();
Console.WriteLine(content);
Could someone help, please?