首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >CommentThreads:插入给403禁止

CommentThreads:插入给403禁止
EN

Stack Overflow用户
提问于 2018-06-12 19:12:51
回答 2查看 1.4K关注 0票数 4

我要因为这个错误而发疯了。据我所知,我正确地遵守了指示。我的范围是YOUTUBE_FORCE_SSL。在绝望中,我试图添加所有谷歌加Scopes没有运气。在设备、模拟器和中,仍然会出现相同的错误。我试图评论的视频是公开的。我有一个Google+配置文件,当我试图发表评论时,它会被注册。

这是完全错误:

代码语言:javascript
运行
AI代码解释
复制
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
    {
      "code" : 403,
      "errors" : [ {
        "domain" : "youtube.commentThread",
        "location" : "Authorization",
        "locationType" : "header",
        "message" : "The callers YouTube account is not connected to Google+.",
        "reason" : "ineligibleAccount"
      } ],
      "message" : "The callers YouTube account is not connected to Google+."
    }

这是我的代码:

代码语言:javascript
运行
AI代码解释
复制
try {
                    HashMap<String, String> parameters = new HashMap<>();
                    parameters.put("part", "snippet");


                    CommentThread commentThread = new CommentThread();
                    CommentThreadSnippet snippet = new CommentThreadSnippet();
                    Comment topLevelComment = new Comment();
                    CommentSnippet commentSnippet = new CommentSnippet();
                    commentSnippet.set("textOriginal", textComment);
                    commentSnippet.set("channelId", channelId);
                    commentSnippet.set("videoId", ytId);

                    topLevelComment.setSnippet(commentSnippet);
                    snippet.setTopLevelComment(topLevelComment);
                    commentThread.setSnippet(snippet);

                    YouTube.CommentThreads.Insert commentThreadsInsertRequest = mService.commentThreads().insert(parameters.get("part"), commentThread);

                    CommentThread response = commentThreadsInsertRequest.execute();
                    Log.i("COMMENT:", response.toString());
                }

添加来自Api的屏幕快照:

您能让CommentThreads:插入与API一起工作吗?如果是这样的话,是怎么做的?

我看到了一个类似问题的答案,这里,他们不能解决这个问题。

任何帮助都是非常感谢的。

编辑1

经过进一步的测试。我有一个旧账户,一切都很好。我试着看看哪些设置可能不同,到目前为止没有运气。

如果我切换到一个YouTube品牌帐户,这也是可行的。

问题仍然存在,它并不适用于所有的Google帐户,即使它们也是Google+帐户。该错误似乎意味着请求不是从Google+帐户发出的。如果谷歌能澄清确切的原因,那就太好了。

还可以在请求帐户所有者的许可后,以编程的方式使帐户有资格进行评论吗?怎么做?

编辑2

根据此页,错误的原因是:

用于授权API请求的YouTube帐户必须与用户的Google帐户合并,以插入注释或注释线程。

如何在应用程序中做到这一点?

编辑3

我想答案可以找到这里。如果没有YouTube频道,您就不能发表评论。

问题是,你不能评论,除非你有一个私人的YouTube频道或登录到您的品牌帐户。使用Google在说明中给出的登录模型不允许使用品牌帐户登录,它们在帐户选择器中不可见。

其结果是,您可以使用具有YouTube品牌帐户的帐户登录,但您将无法使用该帐户进行评论,因为您无法选择一个品牌帐户,除非您要求用户也创建一个私有频道,否则无法解决这个问题。错误消息应该如下所示:

调用方YouTube帐户不是YouTube信道帐户。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-06-12 22:14:31

由于您不能在没有私有YouTube通道的情况下发布评论(请参阅上面的编辑),解决方案将如下所示。如果你能找到一个更好的,请提交!

1)捕捉错误。向警报发出指示。

2)使用以下网址启动Webview:完成

3)监视Webview并确定URL何时更改为以下内容:完成。URL指示已经创建了一个通道。

4)关闭Webview并重新发送授权的API请求。

上面的URL是这里,但是要捕获的错误代码与页面上的错误代码不一样。你应该用“理由”:"ineligibleAccount“来抓一个403。

更新2018年6月29日

我今天回到这个问题上,让它以一种可以接受的方式运作。见下文的实施情况:

1.在没有YouTube频道的用户发布评论后捕获错误403

代码语言:javascript
运行
AI代码解释
复制
if(mLastError.getMessage().contains("403") && mLastError.getMessage().contains("ineligibleAccount")) {
                        // Show Alert with instruction
                        showAlertCreate("Please Create a YouTube Channel!", "You need a personal YouTube Channel linked to your Google Account before you can comment. Don't worry, it's easy to create one!\n\n1) Tap on CREATE below and wait for page to load.\n\n2) Login if needed.\n\n3) Tap CREATE CHANNEL and wait until comment is posted.");
}

警报代码:

代码语言:javascript
运行
AI代码解释
复制
public void showAlertCreate(String title, String description) {
    AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        builder = new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert);
    } else {
        builder = new AlertDialog.Builder(this);
    }
    builder.setTitle(title)
            .setMessage(description)
            .setPositiveButton(R.string.yes_create, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // Start Youtube WebView to create Channel
                    Intent intent = new Intent(mContext, WebViewActivity.class);
                    startActivityForResult(intent, 777);
                }
            })
            .setIcon(android.R.drawable.ic_dialog_alert)
            .show();
}

2.当用户点击在警报中创建时,打开这个WebView

请注意下面的代码,以便在上面发出警告时启动意图:

代码语言:javascript
运行
AI代码解释
复制
// Start Youtube WebView to create Channel
                    Intent intent = new Intent(mContext, WebViewActivity.class);
                    startActivityForResult(intent, 777);

用于WebView的XML:

代码语言:javascript
运行
AI代码解释
复制
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".WebViewActivity">

    <WebView
        android:id="@+id/create_channel"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</android.support.constraint.ConstraintLayout>

WebView代码:

代码语言:javascript
运行
AI代码解释
复制
public class WebViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_view);

        WebView createChannel = findViewById(R.id.create_channel);

        createChannel.setWebViewClient(new WebViewClient() {
            public void onPageFinished(WebView view, String url) {
                if (url!=null && url.contains("https://m.youtube.com/channel_creation_done")) {
                    view.setVisibility(View.INVISIBLE);
                    //Log.i("URLWEB", url);
                    Intent intent = new Intent();
                    intent.putExtra("created", "yes");
                    setResult(RESULT_OK, intent);
                    finish();
                }
            }
        });

        createChannel.loadUrl("https://m.youtube.com/create_channel?chromeless=1&next=/channel_creation_done");

    }
}

3.当用户完成在活动中创建通道步骤时捕获

在onActivityResult()中包括如下内容:

代码语言:javascript
运行
AI代码解释
复制
if (requestCode == 777) {
    if(resultCode == RESULT_OK) {
        // Receive intent from WebView, if new Channel, repost comment/reply
        String created = data.getStringExtra("created");
        if(created.equals("yes")) {
            // Posting the comment again
            getResultsFromApi();
        }
    }
}

不是最干净的解决方案,但有效。

票数 1
EN

Stack Overflow用户

发布于 2021-11-29 05:21:38

如果您已经创建了一个新的帐户,如果您没有评论任何youtube视频,那么它会引发错误:“调用者YouTube帐户没有连接到Google+。”

解决方案:至少在使用新帐户的youtube视频中手动注释,然后尝试API。它运行得很顺利。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50828577

复制
相关文章
Nginx禁止访问该用401还是403
之前在某些文章中看到建议在nginx配置中用return401而不用403,也没说具体原因,最近这不闲了,突然想起来,google了半天也没有任何相关的信息(可能不太会用google),没办法,只能自己实践看看了
李俊鹏
2020/06/15
3.6K0
Nginx禁止访问该用401还是403
PE格式:手工给程序插入ShellCode
PE格式是 Windows下最常用的可执行文件格式,理解PE文件格式不仅可以了解操作系统的加载流程,还可以更好的理解操作系统对进程和内存相关的管理知识,而有些技术必须建立在了解PE文件格式的基础上,如文件加密与解密,病毒分析,外挂技术等,本次实验的目标是手工修改或增加节区,并给特定可执行程序插入一段ShellCode代码,实现程序运行自动反弹一个Shell会话。
王瑞MVP
2022/12/28
4940
PE格式:手工给程序插入ShellCode
【译】HTTP错误码403禁止:意味着什么,怎么修复它
在上网的时候,收到任何的错误码都是让人沮丧的体验。尽管我们已经习惯于404页面找不到,我们在页面迷失的时候,看到可爱的占位符来娱乐我们是很常见的事情了。但是有种更令人困惑的403错误:禁止响应。
Jimmy_is_jimmy
2020/01/03
30.9K0
PE格式:手工给程序插入ShellCode
PE格式是 Windows下最常用的可执行文件格式,理解PE文件格式不仅可以了解操作系统的加载流程,还可以更好的理解操作系统对进程和内存相关的管理知识,而有些技术必须建立在了解PE文件格式的基础上,如文件加密与解密,病毒分析,外挂技术等,本次实验的目标是手工修改或增加节区,并给特定可执行程序插入一段ShellCode代码,实现程序运行自动反弹一个Shell会话。
王瑞MVP
2022/12/24
6200
PE格式:手工给程序插入ShellCode
Springboot 403
如果同时进行了filter和CorsConfiguration的配置,OPTIONS请求会返回403,并且控制台提示 Itdoesnothave HTTP ok status.非常恶心。 网上没有找到相应的解释。
喜欢天文的pony站长
2020/06/29
1.9K0
Springboot 403
Gitlab 403 forbidden
搭建的Gitlab。但今天打开页面的时候显示的是空白页面,上面还有一次文本Forbidden。
匿名用户的日记
2021/12/14
1.3K0
Gitlab 403 forbidden
Swift - 给TableView添加编辑功能(删除,插入)
1,下面的样例是给表格UITableView添加编辑功能: (1)给表格添加长按功能,长按后表格进入编辑状态 (2)在编辑状态下,第一个分组处于删除状态,第二个分组处于插入状态 (3)点击删除图标,删除对应条目 (4)点击添加图标,插入一条新数据
Python疯子
2018/09/06
3.1K0
Swift - 给TableView添加编辑功能(删除,插入)
给网站增加IP黑名单禁止IP访问
突然哪一天,你的网站来了好几百的UV请求都是来自奇怪的源,并且写着:某某流量推广,这些肯定是无用流量,不消费内容,纯粹给他们打广告,就好像在你家里放了个大喇叭,每天在你家里吵吵,别说技术人了,普通人都不能忍,试了好些方法,居然挡不住他们的机器人,想想都是泪,今天决定彻底挡住这些IP的请求,所以,找到一种有效的方法后,终于是安静了很多!
呱牛笔记
2023/05/02
2.7K0
给网站增加IP黑名单禁止IP访问
SpringSecurity 403 forbidden
springboot项目,涉及跨域,跨域问题解决后,整合权限SpringSecurity。 遇到问题:get请求可以正常通过;post请求的OPTIONS请求可以通过,但是post请求403 forbidden 报错。
IT云清
2021/12/10
1.6K0
nginx 403 forbidden
nginx django .conf 配置 nginx python Django 集成总结之-nginx配置
onety码生
2018/11/21
3.2K0
upupw Kangle 访问文件提示{禁止}服务器拒绝请求 403状态页面的解决方法
之前的服务器到期,准备把之前的下载站搬到新服务器上,使用的是 upupw ANK集成板的 Kangle服务器,发现 .crx 和 .apk文件无法访问,跳403状态页面 报错:{禁止}服务器拒绝请求! ,如下图:
德顺
2019/11/13
1.8K0
如何给二维码动态插入图片
很多用户在制作二维码时,会在二维码中嵌入Logo图片,以突显一些标志性信息。如果是批量制作的二维码,需要给每个二维码嵌入不同的图片,这种情况该如何实现呢?下面,小编就给大家演示二维码动态插入图片的操作方法。
神奇像素科技
2021/12/20
1.2K0
如何给二维码动态插入图片
tomcat manager 403问题
版本:Tomcat 8 问题:新安装的tomcat,用其他机器访问tomcat的Server Status、Manager App、Host Manager三个页面均显示403,用本机访问127.0.0.1没有问题。 conf/tomcat-users.xml里已添加配置如下: <role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="tomcat" password="qazwsx" roles="mana
老七Linux
2018/05/31
9520
axios django CSRF 403错误
使用axios直接post django的接口的时候会提示CSRF 403错误 可以在post的data中转入csrftoken 也可以给单个方法关闭 from django.views.decorators.csrf import csrf_exempt,csrf_protect @csrf_exempt def test(request): pass
小贝壳
2020/03/05
1.4K0
优雅的给WordPress插入哔哩哔哩bilibili视频
前排提示,本文转载自:小石博客 给wordpress优雅的插入BiliBili视频
AlexTao
2019/12/12
3.6K0
解决Nginx出现403 forbidden
我是在在本地用虚拟机中通过yum安装nginx的,安装一切正常,但是访问时报403,
用户8832503
2022/03/02
10.8K1
nginx报403 forbidden错误
403 forbidden错误大家应该都熟悉,文件禁止访问,可能是权限问题,也可能是系统问题
opencode
2022/12/26
2.6K0
绕过 403 Api接口方法
GET /api/v1/user/id 403 /api/v1/user/id.json /api/v1/user/id? /api/v1/user/id/ /api/v2/user/id /api
Khan安全团队
2022/04/02
9200
绕过 403 Api接口方法
Nginx 烦人的 403 错误
但是你就是老看到一个 403 的错误,这个绝大部分情况是因为 SELinux 造成的。
HoneyMoose
2022/07/06
6480
Nginx 烦人的 403 错误
ACMSGURU 403 - Scientific Problem
Once upon a time Professor Idioticideasinventor was travelling by train. Watching cheerless landscape outside the window, he decided to invent the theme of his new scientific work. All of a sudden a brilliant idea struck him: to develop an effective algorithm finding an integer number, which is x times less than the sum of all its integer positive predecessors, where number x is given. As far as he has no computer in the train, you have to solve this difficult problem.
Reck Zhang
2021/08/11
4680

相似问题

HTTP POST请求Ionic 3给403禁止

12

文件上传sharepoint给403个禁止错误

15

post请求给403个禁止django ajax

10

去找私人bitbucket回购给403被禁止

416

SoundCloud取artwork_url给403号禁止

11
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档