Error 403 Forbidden whith Youtube API V3
Asked Answered
S

6

13

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);
Sealskin answered 4/4, 2016 at 19:50 Comment(0)
J
7

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

Jenette answered 16/11, 2019 at 11:1 Comment(1)
Youtube Data Api v3 not show more with API restrictions, any idea to resolve currently?Cf
W
3

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.

Wurtz answered 6/4, 2016 at 14:10 Comment(0)
H
2

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

Horehound answered 3/2, 2021 at 5:10 Comment(0)
H
0

The solution for me was creating a new project on Google Developer Console and obtaining a new API Key.

The error for me might be different even though it's still a 403 forbidden error (https://github.com/fent/node-ytdl-core/issues/24#issuecomment-638777960).

Havens answered 4/6, 2020 at 11:11 Comment(0)
A
0

Although this doesn't obviously explain why it works in the browser but not VS (the OP's "Forbidden" message) ... you will also get a 403 if you exceed your "quota", e.g.

{
    "error": {
        "code": 403,
        "message": "The request cannot be completed because you have exceeded your <a href=\"/youtube/v3/getting-started#quota\">quota</a>.",
        "errors": [
            {
                "message": "The request cannot be completed because you have exceeded your <a href=\"/youtube/v3/getting-started#quota\">quota</a>.",
                "domain": "youtube.quota",
                "reason": "quotaExceeded"
            }
        ]
    }
}

quotaExceeded message

Projects that enable the YouTube Data API have a default quota allocation of 10,000 units per day

You Tube API docs

Aeronaut answered 15/3, 2021 at 8:21 Comment(0)
L
0

TO resolve the 403 error.

  1. First go to your Project.
  2. Go to the Enabled API & Services.
  3. Click on the +ENNBLED API SERVICES.
  4. Scroll Down and check for the YouTube data API v3 and click on it and then click on enable. Now it it working Properly.
Loving answered 13/3 at 5:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.