googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.2k stars 3.52k forks source link

Error when trying to change thumbnail #2552

Closed icarojobs closed 5 months ago

icarojobs commented 5 months ago

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

Steps to reproduce

  1. After following the authentication flow and get/set the bearer token, I'm trying to change a thumbnail of specific video. I'm using Laravel too.

Code example

// After flow of authentication....this is my code:
$service = new Google_Service_YouTube($this->client);

$videoId = "XG96bA9Q9OE";
$newThumbnailPath = storage_path('app/thumbs/1/test1.jpg');

$response = $service->thumbnails->set($videoId, [
    'mimeType' =>  'image/jpeg',
    'data' =>  file_get_contents($newThumbnailPath)
]);

dd($response);

Response error:

{
  "error": {
    "code": 403,
    "message": "The thumbnail can't be set for the specified video. The request might not be properly authorized.",
    "errors": [
      {
        "message": "The thumbnail can't be set for the specified video. The request might not be properly authorized.",
        "domain": "youtube.thumbnail",
        "reason": "forbidden",
        "location": "videoId",
        "locationType": "parameter"
      }
    ]
  }
}

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

yash30201 commented 5 months ago

Hi @icarojobs , thanks for raising the issue.

Please make sure your account is verified. For more info, see: 1) https://support.google.com/youtube/answer/72431 2) https://stackoverflow.com/questions/38636310/set-custom-thumbnail-via-youtubeapi-doesnt-work-can-someone-tell-me-why

icarojobs commented 5 months ago

Hi @icarojobs , thanks for raising the issue.

Please make sure your account is verified. For more info, see: 1) https://support.google.com/youtube/answer/72431 2) https://stackoverflow.com/questions/38636310/set-custom-thumbnail-via-youtubeapi-doesnt-work-can-someone-tell-me-why

Wow! This worked! Thank you! 🔥🚀