I am trying to send a GET request to the Constant Contact API using the http package in Meteor. I have generated a API key and a access token. There is a section in the docs about OAuth 2.0, however it mentions I don't need to use it if I am only using one Constant Contact account, which I am.
They have a API testing section and I have tried to take the same url and params in my HTTP GET request in Meteor but it returns
statusCode: 401,
I20170927-06:36:08.874(-7)? content: '[{"error_key":"http.status.unauthorized","error_message":"No authentication is present."}]'
Let me know of any other info I can provide, at this point I am pretty stuck.
Thanks
Here is my code
Server
HTTP.call( 'GET', 'https://api.constantcontact.com/v2/account/info?api_key=random-api-key', {}, function( error, response ) {
if ( error ) {
console.log( error );
} else {
console.log( response );
}
});
You should pass both API Key
and Access Token
:
HTTP.get('https://api.constantcontact.com/v2/account/info?api_key=<API_KEY>', {
headers: {
'Authorization': 'Bearer <ACCESS_TOKEN>'
}
}, function (err, response) {
// do something
});