YouTube API don’t works (local link checker)
-
Hi!
The YouTube API does not seem to work in the local link checker. All calls deliver in details:
403 Forbidden
Unknown YouTube API response received.message: Requests from referer <empty> are blocked.
domain: global
reason: forbiddenI have linked a similar case from @allesrogernet. The remedy is to disable the YouTube API, but this is only a workaround.
Can I change anything on my side to set the missing “referer” header for API requests?
The page I need help with: [log in to see the link]
-
Hi @reiniggen,
I hope you are doing well today!
When you encounter a
403 Forbidden
error with the message indicating that requests from a referer<empty>
are blocked, it’s typically due to the YouTube API’s security measures, which are designed to prevent unauthorized use of your API key. The YouTube Data API allows you to specify which domains or IP addresses are allowed to use your API key, and if a request comes from an unspecified source—or in this case, an empty referer—it gets blocked.We are checking your request with our BLC team if it is possible to provide any other solution or workaround except disabling YouTube API and will inform you accordingly.
Thanks for the patience while we are looking into this.
Kind regards,
ZaferI don’t know why no referer is sent by the plugin when the YouTube API is called. My domain was specified for the API key – that can’t be the problem. If I deactivate the YouTube API in the plugin settings, YouTube links are called with the referer.
Kind regards,
GarrettHi @reiniggen,
Hope this message finds you well.
The issue might be the video privacy settings or your API Key.
I embedded a video from our YY, which was returning a warning, after adding my API Key, YoutTube is returning OK:
My YT API Key:
Is it possible for you can share the video, so we can test it on our side?
Bets regards,
LauraHi @wpmudevsupport3,
I have now taken an official trailer to show this problem. I created my YouTube API key especially for this and saved it in the settings.
This is what the test page looks like:
https://img.nagelix.com/youtube-links-page.pngAnd here are the warnings in the plugin:
https://img.nagelix.com/youtube-links-warnings.pngThe video is this:
https://www.youtube.com/watch?v=d96cjJhvlMAI hope it helps with reproducing. For the API key, I have granted access permissions to both my domain and all subdomains.
Best regards,
GarrettHi @reiniggen
I hope you’re well today!
I just tested this particular YT URL on two test setups of mine, using my own API key, and in both cases I couldn’t replicate that issue.
Both setups checked this link and returned it as not broken with “200 OK” HTTP status.
The error that you are getting seems to come down to that “empty referrer” part (as you already noticed in initial post) but I’m wondering why it even is empty. It seems that there is something specific either on site or on server that does that as Broken Link Checker doesn’t really attempt to manipulate it in anyway.
Can you try a small test, please?
1. enable WordPress debugging on site by adding following lines to the “wp-config.php” file of your site, right above the “/* That’s all, stop editing */” line:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', false ); define( 'WP_DEBUG_LOG", true );
2. then add this code to the sit as Must Use plugin:
<?php add_filter( 'http_request_args', 'blc_test_http_response_args', 999, 2 ); function blc_test_http_response_args( $args, $url ) { if ( strpos( $url, 'youtube' ) !== false ) { error_log( print_r( $args, true ) ); } return $args; }
– create an empty file with a .php extensions (e.g. “blc-args-test.php”) in the “/wp-content/mu-plugins” folder of your site’s WordPress install
– copy above code and paste it into that file
– save the file
3. then in Broken Link Checker find that YT link where it’s reported as broken and click “recheck” option.
4. after that look into the file “/wp-content/debug.log” on the server and
a) see if there are any errors/fatal errors or similar reported that may seem related to Broken Link Checker
b) and look for output similar to this:
[19-Mar-2024 14:36:18 UTC] Array ( [method] => GET [timeout] => 30 [redirection] => 5 [httpversion] => 1.0 [user-agent] => WordPress/6.4.3; http://yoursite.here [reject_unsafe_urls] => [blocking] => 1 [headers] => Array ( ) [cookies] => Array ( ) [body] => [compress] => [decompress] => 1 [sslverify] => 1 [sslcertificates] => /some-path-here/certificates/ca-bundle.crt [stream] => [filename] => [limit_response_size] => )
If it’s there (or there are errors), share it with us (note: you may want to mask path in the [sslcertificates] line for safety).
Best regards,
AdamThe log entry looks exactly as in your example:
[19-Mar-2024 15:33:59 UTC] Array ( [method] => GET [timeout] => 30 [redirection] => 5 [httpversion] => 1.0 [user-agent] => WordPress/6.4.3; https://my-website.com [reject_unsafe_urls] => [blocking] => 1 [headers] => Array ( ) [cookies] => Array ( ) [body] => [compress] => [decompress] => 1 [sslverify] => 1 [sslcertificates] => /my-path/wp-includes/certificates/ca-bundle.crt [stream] => [filename] => [limit_response_size] => )
I hope it helps.
Best regards,
GarrettHi @reiniggen,
I’m afraid, the above logs don’t help much in ruling out the issue. I also tested in my test server and can confirm there isn’t any 403 error picked when tested with the given URL.
Just to be sure are you testing in a site which is public or a local site?
Since there are empty headers picked. Do you have a test or staging site? Possible to check and see how it behaves if you temporarily disable all the plugins except BLC in your staging site?
The above steps would help in giving a better idea of what might be causing it.
Please do let us know how that goes. Looking forward to your response.
Kind Regards,
Nithin
Hi @reiniggen,
Since we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to open a new thread if you have new queries.
Kind Regards
Nithin
- The topic ‘YouTube API don’t works (local link checker)’ is closed to new replies.