I've managed to receive the access_token
, browsing to https://api.github.com/user?access_token=ACCESS_TOKEN_HERE
works very well and the browser displays all my information.
But when I'm trying to get these information with ASP.NET (C#), I get an error:
The remote server returned an error (403) Forbidden.
Here is the code I'm using to make an Get Request.
WebRequest request = WebRequest.Create("https://api.github.com/user?access_token=" + access_token);
request.Method = "GET";
WebResponse response = request.GetResponse(); //Error Here
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string result = reader.ReadToEnd();
I monitored the request and response in my Firefox when I directly access the URL (which works). I had to set the right content type. I added the following and everything worked.