It has been some time that you've asked dont know if you've already find out but this would help to others as well.
There is some informatical issues in pinterest doc.
- you need to pass client id and client secret to this curl request with other required parameters.
For e.g
$vars = array(
"grant_type" => "authorization_code",
"code" => <code_you_get_from_step_one>,
"client_id" => env("PINTEREST_CLIENT_ID"),
"client_secret" => env("PINTEREST_CLIENT_SECRET"),
"redirect_uri" => 'http://localhost:8000/auth/pinterest/callback'
);
$headers = [
'Authorization: Basic '.base64_encode("$client_id:$client_secret"),
'Content-Type: application/x-www-form-urlencoded'
];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://api.pinterest.com/v5/oauth/token");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($vars));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec ($ch);
curl_close ($ch);
dd($result);
2)If you're attempting with like above curl request As CBroe has mentioned in here As Manual says about CURLOPT_POSTFIELDS "if value is an array, the Content-Type header will be set to multipart/form-data "
That appears to be colliding with the application/x-www-form-urlencoded you are trying to send here.
Pass the data as a URL-encoded string instead, using http_build_query.
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($vars));
Hope this is going to be helpful for other developers who are trying to integrate pinterest oauth.