YouTube 嵌入式播放器抛出 401 错误 [英] YouTube embedded player throwing 401 errors

查看:40
本文介绍了YouTube 嵌入式播放器抛出 401 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Angular 应用程序中使用 YouTube HTML5 嵌入播放器,我看到这些 401 错误在页面加载 (Chrome) 时弹出.视频仍然可以正常播放,但我想知道发生了什么.我试过暂停 AdBlock,但我看到了同样的错误.

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.

这是失败的代码:

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
}

推荐答案

Youtube API 401错误定义如下:

Youtube API 401 error is defined as follows:

此错误表明用户的 Google 帐户未关联,这意味着用户拥有 Google 帐户但没有YouTube 频道.这些用户可以访问许多功能取决于用户授权,例如对视频进行评级或添加视频到 watch_later 播放列表.然而,作为一个例子,用户需要一个 YouTube 频道才能上传视频.一个用户有 Gmail 帐户或 Android 设备肯定有 Google帐户,但可能尚未将该 Google 帐户关联到YouTube 频道.

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.

如果您尝试使用 OAuth 2.0 服务,通常会看到此错误账户流.YouTube 不支持服务帐户,如果您尝试使用服务帐户进行身份验证,您将获得此信息错误.

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.

YouTube API 博客发帖介绍 Google 帐户支持还讨论了youtubeSignupRequired 错误更详细.虽然博文解释API 2.1版本的错误,错误的意思是仍然适用.

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.

这篇关于YouTube 嵌入式播放器抛出 401 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆