Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Youtube Analytics APIs - How do i can fix forbidden 403 error?

$
0
0

I am trying to get youtube channel stats using Youtube APIs, it is giving me error like below. I have also mentioed the API script that I get from Youtube APIs Explore (API Playground method)

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

enter image description here

UPDATE

Request that is being made,(get from Youtube APIs Explorer)

$client = new Google_Client();$client->setApplicationName('API code samples');$client->setScopes(['https://www.googleapis.com/auth/youtube.readonly',]);$client->setAuthConfig('YOUR_CLIENT_SECRET_FILE.json');$client->setAccessType('offline');$authUrl = $client->createAuthUrl();printf("Open this link in your browser:\n%s\n", $authUrl);print('Enter verification code: ');$authCode = trim(fgets(STDIN));$accessToken = $client->fetchAccessTokenWithAuthCode($authCode);$client->setAccessToken($accessToken);$service = new Google_Service_YouTubeAnalytics($client);$queryParams = ['dimensions' => 'ageGroup,gender','endDate' => '2022-01-01','ids' => 'channel==UCTVujeJyggsTZnlnsdaP0dQ','metrics' => 'viewerPercentage','sort' => 'gender,ageGroup','startDate' => '2017-01-01'];$response = $service->reports->query($queryParams);print_r($response);

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>