How to provide Youtube authentication token in PHP cURL How to provide Youtube authentication token in PHP cURL curl curl

How to provide Youtube authentication token in PHP cURL


Look to this guide:

https://developers.google.com/youtube/2.0/developers_guide_protocol#OAuth2_Calling_a_Google_API

You need to add a header containing: Authorization: Bearer ACCESS_TOKEN

$headers = array('Authorization: Bearer ' . $access_token);curl_setopt($ch_subs, CURLOPT_HTTPHEADER, $headers);

You can also pass the token as part of the Get request:

curl_setopt($ch_subs, CURLOPT_URL, 'https://gdata.youtube.com/feeds/api/users/default/subscriptions?v=2&access_token=' . $access_token);