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

YouTube Analytics API returns Forbidden error. How can I get analytics data with Viewer permission?

$
0
0

Another team owns a YouTube channel and I was invited as Viewer.
I can check analytics data through YouTube Studio.
Now I am struggling to download the data by using YouTube Analytics API.

The owner team provided me Client ID and Secret by enabling YouTube related APIs.
However I cannot access their channel data with Forbidden error.

I tried to download with following python code, but it returns "Forbidden"
Any suggestion/solution to download analytics data with Viewer permission?

SCOPES = ['https://www.googleapis.com/auth/yt-analytics.readonly','https://www.googleapis.com/auth/youtube.readonly']API_SERVICE_NAME = 'youtubeAnalytics'API_VERSION = 'v2'CLIENT_SECRETS_FILE = 'client_secret.json'def get_service():  flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)  credentials = flow.run_local_server(port=8888)  return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)def execute_api_request(client_library_function, **kwargs):  response = client_library_function(    **kwargs  ).execute()  print(response)if __name__ == '__main__':  os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'  youtubeAnalytics = get_service()  execute_api_request(      youtubeAnalytics.reports().query,      ids='channel==UCxxxxxxxxxxxx',      startDate='2024-12-01',      endDate='2024-12-10',      metrics='estimatedMinutesWatched,views,likes,subscribersGained',      dimensions='day',      sort='day'  )

Viewing all articles
Browse latest Browse all 3831

Trending Articles



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