The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

OAUTH2 Not Authorized error

Highlighted
Member

OAUTH2 Not Authorized error

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://173.168.9.110: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.
reader.Close();
respStream.Close();
response.Close();

1 REPLY 1
Highlighted
Employee

Re: OAUTH2 Not Authorized error

Hey,

 

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.

Ryan Davis
Quality Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured