alaouy / YouTube

🔥 Laravel PHP Facade/Wrapper for the Youtube Data API
MIT License
778 stars 204 forks source link

Exception: Error 403 Requests from referer <empty> are blocked #160

Closed EPauli closed 3 years ago

EPauli commented 3 years ago

I'm getting this error message.

Exception: Error 403 Requests from referer are blocked. : forbidden in file /Users/epauli/Sites/laravel.zite.eu/vendor/alaouy/youtube/src/Youtube.php on line 642

I think something has been changed in the YouTube API that makes an referrer required. How can I set an referrer?

alaouy commented 3 years ago

@EPauli Like explained in the readme doc:

// By default, if the $_SERVER['HTTP_HOST'] header is set,
// it will be used as the `Referer` header. To override
// this setting, set 'use-http-host' to false during
// object construction:
$youtube = new Youtube(config('YOUTUBE_API_KEY'), ['use-http-host' => false]);
Anamcoollzz commented 1 year ago

its doesn't work sometime, but sometimes its work. That not stabil

cotiga commented 1 year ago

Hi, i have the same problem. The identifiers and access seem correctly informed. The $_SERVER['HTTP_HOST'] corresponds to the domain accepted on the API. I don't know where to look...

KrishenK0 commented 1 year ago
X-Origin: https://youtube.com

Maybe you can try by adding the header in the function api_get(), for my application I have to add this header, or I get the error 403.