OAuth error - BAD_CLIENT_ID

Hi!

I’m using a developer account to set up an app for internal use with our portal.
However, I can’t seem to get the OAuth authentication working, as it always returns the following error:

“status”:“BAD_CLIENT_ID”,“message”:“missing or unknown client id”

Following is my PHP code to send the request:

$CLIENT_ID = “fc7a3a6-354b-4db7-xxxx-xxxxxxxxxxxx”;
$CLIENT_SECRET = “ae468672-c3f0-41cf-xxxx-xxxxxxxxxxxx”;
$REDIRECT_URI = “someurl.com”;

$code=$_GET[“code”];

$data = array(
‘grant_type’ => ‘authorization_code’,
‘client_id’ => $CLIENT_ID,
‘client_secret’ => $CLIENT_SECRET,
‘redirect_uri’ => $REDIRECT_URI,
‘code’ => $code);

$ch = curl_init(‘https://api.hubapi.com/oauth/v1/token’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( ‘Content-Type: application/x-www-form-urlencoded;charset=utf-8’));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$result = curl_exec($ch);

I’ve read a bunch of similar topics on this forum, but can’t seem to find what I’m doing wrong here…?

Hi @raymond, Happy to help. To troubleshoot effectively, though, I’ll need a bit more information. Would you share:

  1. Your APP ID.
  2. The portal ID you’re trying to request access to.
  3. The full error you received from HubSpot, including the status code.

Hi Connor,

Thanks for your reply. Strangely, the exact same script does seem to work from a different domain…

Consider the problem solved