YouTube Analytics API Error: Forbidden

I authenticated and built my request and received a 403 response as Forbidden.

I am authenticated using httr example

# 1. Find OAuth settings for google: google <- oauth_endpoint(NULL, "auth", "token", base_url = "https://accounts.google.com/o/oauth2") # 2. Register an application at https://code.google.com/apis/console#access myapp <- oauth_app("google", "{my app id}.apps.googleusercontent.com", secret = "{my secret}") # 3. Get OAuth credentials cred <- oauth2.0_token(google, myapp, scope = "https://www.googleapis.com/auth/yt-analytics.readonly") 

After authorization in the browser, the R-console prints "Full Authentication".

Request

 query <- "https://www.googleapis.com/youtube/analytics/v1/reports? ids=channel%3D%3D{my channel id} &start-date=2013-01-01 &end-date=2013-07-31 &metrics=views &dimensions=day" 

The token for authorization is transferred in the header as

 token <- paste("Authorization: Bearer ",cred[[1]], sep="") 

I tried the request using httr and RCurl

 # RCurl api.response <- getURL(query, httpheader = token) # httr - I think this is the right way to add the token to the header url_signer <- sign_oauth2.0(cred[[1]], as_header = TRUE) api.response <- GET(query, config = url_signer) 

Api.response is unfortunately not very descriptive

 { "error": { "errors": [ { "domain": "global", "reason": "forbidden", "message": "Forbidden" } ], "code": 403, "message": "Forbidden" } } 

I'm not sure where else to look and read the documentation.

+4
source share
1 answer

From experience, 403 API Analytics Prohibited Response may mean several things about the video you are trying to extract analytic information for:

  • Video is closed and not uploaded by you.
  • You have not claimed ownership of the video
  • Video does not exist or was deleted by bootloader
  • User account completed
  • You have a complaint about a video that relates to one of the following statuses:
    • Inactive
    • Potential

If in doubt, contact your partner / TAM manager. Hope this helps!

0
source

Source: https://habr.com/ru/post/1495739/


All Articles