We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Invalid_Client: Client ID Mismatch


Invalid_Client: Client ID Mismatch


I'm having a problem granting OAuth2 authorization for my application. Here is the code that I'm using to request authorization:


$apikey = "APIKEY";
$consumersecret = "CONSUMERSECRET";
$url = "http://websiteaddress/lib/plugins/constantContact/authorize.php";

if(isset($_GET["code"])) {
	require_once ('ConstantContact.php');
	// Instantiate a new oAuth2 object by passing in all the necesssary
	// information to authenticate
	$oAuth2 = new CTCTOauth2 ( $apikey, $consumersecret, $url, $_GET ["code"] );
	// trade your code in for an access token by doing a POST
	$token = $oAuth2->getAccessToken ();

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Authorize token</title>

	if(isset($_GET["code"])) {
		echo "Your token is: " . $token;
	} else {
		// you must encode your redirect URL and the link contains the variables from config.php
		$theRequest = urlencode($url);
		echo "<a href='https://oauth2.constantcontact.com/oauth2/oauth/siteowner/authorize?response_type=code&client_id=" . $apikey . "&redirect_uri=" . $theRequest . "'>Authorize here</a>";

When I click "Authorize Here" I am taken to Constant Contact where I can grant access to the script. When I do this, it takes me back to the correct URL on my server. However, I run into a problem when i try to get the token via POST. The error message that outputs is:

  "error": "invalid_client",
  "error_description": "Client ID mismatch"

 I take it that the client ID is the API key, but it is the same one used in both parts of the script. Do you know what I'm doing wrong? Thanks for your help!




Yes, you are correct, the Client ID is your API key, so double check that the value is set correctly in your code.  Also, this line:


$theRequest = urlencode($url);


Was changed from this in our sample:


$theRequest = urlencode ( $verificationURL );



Is the value for $url (verificationURL in our sample) set to the redirect URL?  You are using the same username, password, and api key throughout your OAuth2 flow, right?


Best Regards,

Shannon W.

API Support Specialist


Strangely, after rechecking the values, and resubmitting the API key request, things seem to work now. Oddly, I checked and rechecked last night with no success, but it works today. Could be that I was working too late last night! Anyway, I think I'm good now. Thanks for responding even though it was just apparently an error on my part!

Developer Portal

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

Visit Page