错误403禁止使用Youtube API V3

gia*_*lla 6 youtube-api

我有Youtube Api v3的问题.问题是想要从上传的视频中获取信息,在执行视频的检索信息时,我收到错误403 Forbidden.

如果我运行网址,我使用浏览器返回Json me所有视频数据.

Visual Studio错误

截图1

浏览器中的相同网址.

截图2

 if (videoId != "")
            {

                // If the video has the same description as a video and uploaded to YouTube, then I have removed that was uploaded earlier and upload the newrequest.Service.QueryClientLoginToken();
                //Uri urlVideo = new Uri(String.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads/{1}", hipoConfig.canal_youtube, videoId)); This is This is the URL of the version 2.0
                Uri urlVideo = new Uri(String.Format("https://www.googleapis.com/youtube/v3/videos?id={0}&key={1}&part=snippet", videoId, hipoConfig.clave_api));

                Video ExistingVideo = request.Retrieve<Video>(urlVideo);
                log.escribirInfoLog("Informacion: El video " + ExistingVideo.VideoId + "se elimina de YouTube para ser sustituido");

                request.Delete(ExistingVideo);
Run Code Online (Sandbox Code Playgroud)

小智 7

也不适合我,访问 youtube API 时收到 403 错误。

在 API 凭据页面的“API 限制”中添加了它以限制 YouTube ABI,现在它工作正常。 在此输入图像描述


Mr.*_*bot 3

您是否尝试过添加 OAuth 来授权您的请求?检查YouTube 数据 API - 错误中的代码错误描述后:

禁止 (403)

禁止访问。该请求可能未得到正确授权。

您可以尝试使用YouTube 数据 API 概述上的此文档作为指南来添加 OAuth。

如果您的应用程序将使用任何需要用户授权的API方法,请阅读身份验证指南以了解如何实现OAuth 2.0授权。