youtube-data-apihttp-status-code-307

I get a http errorcode 307 when trying to load Youtube Data api?


I try to load the Youtube data API (by injecting it in my header section).

It used to work out perfectly, but suddenly I only gets 307 response codes (and no real content).

307 is temporary_redirect, and this page: https://developers.google.com/youtube/v3/docs/core_errors

tells me to go fetch the content by forwarding the request to the location stated in the Location header of the 307 response. The thing is that there isn't anything in the Location header of the response! :-(

Does anyone know what is happening, how to fix it, and also how to prevent it from happening ever again? (should I create code to resend the request to a new URI when getting 307 responses??)

This is my injection code (but it used to work perfectly):

var YTDtag = document.createElement('script'),
            YTItag = document.createElement('script');
        YTDtag.src = "https://apis.google.com/js/client.js?onload=apiReady"; // load YouTube data API
        YTItag.src = "https://www.youtube.com/iframe_api"; // load YouTube Iframe API
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(YTDtag, firstScriptTag);
        firstScriptTag.parentNode.insertBefore(YTItag, firstScriptTag);

but the only response I get from https://apis.google.com/js/client.js?onload=apiReady is the 307 number, and thus my apiReady never gets called.

If I try to load the page "manually" by putting it in a browser location field, it seems to load allright - but not when I try to load it through my js? :-/


Solution

  • To narrow down this problem, check the following:

    If that’s not the case, and the problem is reproducible on other machines as well – then you might need to go and ask Google support for help.


    (Added as an answer on OP’s request. Probably not the definite answer on this, but if this helped debug the issue or narrow it down, so be it … )