403删除YouTube视频时出现禁止的错误 [英] 403 Forbidden error when deleting YouTube video

查看:615
本文介绍了403删除YouTube视频时出现禁止的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直使用OAuth方法在YouTube上上传,更新和删除视频。直到2月12日,所有这些程序都停止工作,这一切都运行良好。现在,当我去删除YouTube视频时,出现以下错误:

code:403,
message:



我知道OAuth流程已经过期,因此您无法删除您试图删除的视频。正在工作,因为我可以获取该令牌并刷新该令牌已过期。我正在使用Google提供的最新PHP库(使用作曲家安装)。我可以通过以下方式获得有效YouTube视频的信息:

  $ videoId =xxxxxxx; //视频在YouTube上的ID 
$ youtube->视频 - >列表视频(snippet,数组('id'=> $ videoId));

但是,删除调用会给出上述错误。

  $ youtube->视频 - >删除($ videoId); 

由于listVideos有效,这证实client_id,密钥和令牌是正确的。我还将范围设置为以下内容:

  $ client-> setScopes(array('https:// www。 googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.upload',
'https://www.googleapis.com/auth/youtubepartner' ));

我还检查了在Google API中设置的凭据和配额是否正常。我认为可能已经达到了配额,但似乎并非如此。我确实在2月初看到YouTube上的一封电子邮件,称他们有新的服务条款和开发者政策。我检查了所有那些,但似乎没有指出我遇到的问题?



不知道还有什么要尝试的?

>解决方案

for-google-calendar-v3 / 40481457#40481457>问题,重点关注如何使用Google API刷新令牌。



您的错误通常会导致通过:




  • 当令牌过期时

  • 令牌的作用域(这很重要)

  • 如果令牌无效



如果令牌无效,您可以像这样排除故障:




  • 从您的数据存储或数据库中删除访问令牌。 使用刷新令牌获取新的访问令牌(如果您使用的是刷新令牌)

  • 尝试再次调用API调用。如果它起作用,你就很好!如果不是... ...
  • 根据tokenInfo API检查访问标记


  • 如果它仍然存在无效,做一个完整的答案




希望这有助于!


I have been using the OAuth approach to upload,update and delete videos on YouTube. That all has been working fine until about February 12th where all of those processes stopped working. Now when I go to delete a YouTube video I get the following error:

"code": 403, "message": "The video that you are trying to delete cannot be deleted. The request might not be properly authorized."

I know that the OAuth process is working because I can get the token and refresh the token if it has expired. I'm using the latest PHP library that Google have provided (installed using composer). And I can get information about a valid YouTube video by making the following call:

$videoId = "xxxxxxx"; //id of video on YouTube
$youtube->videos->listVideos("snippet", array('id' => $videoId));

But then the delete call gives that error above.

$youtube->videos->delete($videoId);

Since the listVideos works, that confirms that the client_id, secret key and token is correct. I also am setting the scopes to be the following

$client->setScopes(array('https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.upload',
'https://www.googleapis.com/auth/youtubepartner'));

I also checked that the credentials and quotas set in the Google APIs are ok. I thought that maybe the quota had been reached but that doesn't appear to be the case. I did see an email from YouTube in early february saying that they have a new terms of service and a developer policies. I reviewed all that but nothing in there appears to point to the issue I am having?

Not sure what else to try?

解决方案

Try to check my answer here in this SO question that focus on how to Refresh Token with the Google API.

Your error usually caused by:

  • When the token expires
  • The token’s scope (this is important)
  • If the token is invalid

If the token is invalid you can troubleshoot like this:

  • Remove the access token from your datastore or database.

  • Use the refresh token to acquire a new access token (if you are using a refresh token)

  • Try to make the API call again. If it works, you’re good! If not …

  • Check the access token against the tokenInfo API

  • If it’s still invalid, do a full reauth

Hope this helps!

这篇关于403删除YouTube视频时出现禁止的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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