Error 403 Forbidden whith Youtube API V3

2019-02-23 03:16发布

I have a problem with Youtube Api v3. The problem is that wants to obtain information from an uploaded video, when performing Retrieve information for video, I get the error 403 Forbidden.

If I run the url I am using the browser returns Json me with all video data.

Visual Studio Error

screenshot 1

Same Url in Browser.

screenshot 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);

标签: youtube-api
1条回答
淡お忘
2楼-- · 2019-02-23 04:05

Have you tried adding OAuth to authorize your request? Upon checking the code error description in YouTube Data API - Errors:

forbidden (403)

Access forbidden. The request may not be properly authorized.

You can try adding OAuth using this documentation on YouTube Data API Overview as a guide.

If your application will use any API methods that require user authorization, read the authentication guide to learn how to implement OAuth 2.0 authorization.

查看更多
登录 后发表回答