I am going through the steps to get my OAUTH2 access token. The first part works fine and I get back the code and username. When I try to use the code I get a 401 - Not Authorized error. Here is the code I am using.
string auth = "https://oauth2.constantcontact.com/oauth2/oauth/token?grant_type=authorization_code&client_id=APIKEY... from first step&redirect_uri=https://126.96.36.199:83/Home";
HttpWebRequest request = HttpWebRequest.Create(auth) as HttpWebRequest;
request.Method = "POST";
WebResponse response = request.GetResponse();
Stream respStream = response.GetResponseStream();
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
// Clean up the streams.
The 401 would be issued for a few reasons. If you recieved this 401 erorr more than a handful of times it is a good possibility that you are locked out of your account. Otherwise, you may be passing in the credentials incorrectly. You can pass them through the authorization headers as
Authorization: Bearer the_token
You can read more about this here.
Please let me know if this helps.