authorization error


authorization error

Hello!, I need to make a simple integration with Constant Contact to work.

I have an app registered:

I have a Mashery account:



and I generated an authorization token:



I have a simple PHP/CULR based function which collects the data and sends it to Constant contact, as described here>

The code is pretty simple:

$body = array(

            "email_address" => $email_address,

            "first_name" => $first_name,

            "last_name" => $last_name,




          $header[]="Content-Type: application/json";

            $header[]="Authorization: Bearer ".$token;

        $this->_log(json_encode($header),'Header: ');

        $this->_log(json_encode($body),'Request: ');

        $ch = curl_init("");

        curl_setopt($ch, CURLOPT_HTTPHEADER,$header);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_POST, 1);

        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

        $server_output = curl_exec($ch);

        $this->_log($server_output,'Response: ');


And the output also looks ok:

2021-02-08 11:59:38
Header: : ["Content-Type: application\/json","Authorization: Bearer 7855b000-f840-4a1e-aac1-cfc545382905"]

2021-02-08 11:59:38
Request: : {"email_address":"","first_name":"Denes","last_name":" Szekely","list_memberships":["fc3464f2-9a6e-11ea-9a0f-d4ae52844390"]}

2021-02-08 11:59:38
Response: : {"error_key":"unauthorized","error_message":"Unauthorized"}

The Header and the body in the above log entry are JSON encoded for readability. My problem is that I am getting this Unauthorized error. I even tried to test my code on the link found on dev portal, and that worked. I am clueless now, and any help is greatly appreciated!

Developer Portal

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

Visit Page