I am trying to authenticate requests to an api for a website using DotNetOpenAuth in C#. My code is as follows:
var serverDescription = new AuthorizationServerDescription();
serverDescription.AuthorizationEndpoint = new Uri("https://--website--/authorize");
serverDescription.TokenEndpoint = new Uri("https://--website--/token");
serverDescription.ProtocolVersion = ProtocolVersion.V20;
var client = new WebServerClient(serverDescription);
client.ClientIdentifier = "--App Key--";
client.ClientCredentialApplicator =
ClientCredentialApplicator.PostParameter("--App Secret--");
var token = client.GetClientAccessToken();
var request = (HttpWebRequest)WebRequest.Create("https://--website--/api/v1/me");
request.Method = "GET";
client.AuthorizeRequest(request, token);
var response = request.GetResponse();
var postreqreader = new StreamReader(response.GetResponseStream());
var json = postreqreader.ReadToEnd();
The code gets the access token fine, it then creates a web request for the authenticated api method.
Upon the request.GetResponse() line, I get a 404 error.
I am sure that this web address exists, I can visit it in my browser but I get a 500.
Aditionally, if I remove the line: client.AuthorizeRequest(request, token); then the response given is a 500 error. So clearly the address exists, but it looks like something to do with adding the authorization headers causes it to give a 404.