Skip to main content
Question

Error in Authorization Code Flow

  • May 22, 2025
  • 1 reply
  • 19 views

Forum|alt.badge.img

Hey there, 

I am using OAuth 2.0 (User or Client Authentication) App, i keep getting this error when i am sending requesting for access_token. 

{"error":"invalid_client","error_description":"The client credentials are invalid"}

I have tried everything, checked all the configurations of the app.

Here's the code.

function Box_Integration_getAccess($code)
{

$access_token_url = "https://api.box.com/oauth2/token";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $access_token_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'grant_type'=>'authorization_code',
'code'=>''.$code.'',
'client_id'=>'img6v9bjmroh620mwmu25x2pzxhwm7ss',
'client_secret'=>'REDACTED'
]));
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
"Content-Type: application/x-www-form-urlencoded"
));
$response = curl_exec($ch);
curl_close($ch);
return $response;

}

Please help!!!

1 reply

Forum|alt.badge.img

Hey Sehar, 

It looks like you're missing a few of the required parameters for using a client credentials grant. Please take a look at the cURL sample at the bottom of this page: https://developer.box.com/guides/authentication/client-credentials/. 

Best,

Kourtney, Box Developer Advocate