Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 403 Forbidden whith Youtube API V3

Tags:

youtube-api

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);
like image 437
gianni Sussalla Avatar asked Apr 04 '16 19:04

gianni Sussalla


3 Answers

Wasn't working for me either, was getting a 403 for accessing the youtube API.

in the 'API Restrictions' on the APIs credentials page added it to restrict to the YouTube ABI, now it's working fine. enter image description here

like image 104
Ali Avatar answered Oct 07 '22 05:10

Ali


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.

like image 42
Mr.Rebot Avatar answered Oct 07 '22 05:10

Mr.Rebot


For me the problem was Youtube API wasn't activated Please check this

Visit the Enabled APIs page. In the list of APIs, make sure the status is ON for the YouTube Data API v3.

So you need to check if Check if youtube API v3 is enabled on your project https://console.developers.google.com/apis/enabled

like image 35
Black Mamba Avatar answered Oct 07 '22 06:10

Black Mamba