# OAuth error - BAD\_CLIENT\_ID

**URL:** <https://community.hubspot.com/t/oauth-error-bad-client-id/11293>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [October 19, 2018, 10:52am UTC](https://community.hubspot.com/t/oauth-error-bad-client-id/11293 "2018-10-19T10:52:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raymondvdrots](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/raymondvdrots/32/99730_2.png) [@raymondvdrots](https://community.hubspot.com/u/raymondvdrots)\
**Post date:** [October 19, 2018, 10:52am UTC](https://community.hubspot.com/t/oauth-error-bad-client-id/11293/1 "2018-10-19T10:52:08Z")

</div>

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](https://someurl.com/hubspot/auth.php)”;

$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](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…?

---

<div class="post-metadata">

**Author:** ![cbarley](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cbarley/32/82559_2.png) [@cbarley](https://community.hubspot.com/u/cbarley)\
**Post date:** [October 22, 2018, 4:44pm UTC](https://community.hubspot.com/t/oauth-error-bad-client-id/11293/2 "2018-10-22T16:44:26Z")

</div>

Hi [@raymond](https://community.hubspot.com/u/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.

---

<div class="post-metadata">

**Author:** ![raymondvdrots](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/raymondvdrots/32/99730_2.png) [@raymondvdrots](https://community.hubspot.com/u/raymondvdrots)\
**Post date:** [October 23, 2018, 8:30am UTC](https://community.hubspot.com/t/oauth-error-bad-client-id/11293/3 "2018-10-23T08:30:02Z")

</div>

Hi Connor,

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

Consider the problem solved ![]()
