YouTube embedded player throwing 401 errors

醉酒当歌 提交于 2019-12-11 07:27:45

问题


I'm using the YouTube HTML5 embed player in an Angular app and I'm seeing these 401 errors pop up on page load (Chrome). Videos still play fine, but I'm wondering what's going on. I've tried pausing AdBlock and I see the same errors.

www-embed-player.js:301 POST https://www.youtube.com/youtubei/v1/log_event?alt=json&key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9xx 401 ()

www-embed-player.js:301 POST https://www.youtube.com/youtubei/v1/log_interaction?alt=json&key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9xx 401 ()

I've been using this code for months and haven't seen this until now.

This is the code that's failing:

function Ce(a, b, c, d, e, f, g) {
    function h() {
        4 == (k && "readyState"in k ? k.readyState : 0) && b && Pd(b)(k)
    }
    c = void 0 === c ? "GET" : c;
    d = void 0 === d ? "" : d;
    var k = se();
    if (!k)
        return null;
    "onloadend"in k ? k.addEventListener("loadend", h, !1) : k.onreadystatechange = h;
    k.open(c, a, !0);
    f && (k.responseType = f);
    g && (k.withCredentials = !0);
    c = "POST" == c;
    if (e = xe(a, e))
        for (var m in e)
            k.setRequestHeader(m, e[m]),
            "content-type" == m.toLowerCase() && (c = !1);
    c && k.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    k.send(d);
    return k
}

回答1:


Youtube API 401 error is defined as follows:

This error indicates that the user has an unlinked Google Account, which means that the user has a Google Account but does not have a YouTube channel. Such users can access many features that are dependent on user authorization, such as rating videos or adding videos to a watch_later playlist. However, as an example, the user would need a YouTube channel to be able to upload a video. A user who has a Gmail account or an Android device is certain to have a Google Account but may not have already linked that Google Account to a YouTube channel.

This error is commonly seen if you try to use the OAuth 2.0 Service Account flow. YouTube does not support Service Accounts, and if you attempt to authenticate using a Service Account, you will get this error.

The YouTube API blog post introducing Google Account support also discusses the youtubeSignupRequired error in more detail. Although the blog post explains the error for API version 2.1, the meaning of the error is still applicable.



来源:https://stackoverflow.com/questions/47504749/youtube-embedded-player-throwing-401-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!