I'm using YouTube Analytics API to extract some channels information using something like:
result = execute_api_request(
youtubeAnalytics.reports().query,
ids="channel==" + channel_id,
startDate='2023-11-01',
endDate=today,
metrics='views,likes,subscribersGained,estimatedMinutesWatched,averageViewDuration,shares',
dimensions='day,creatorContentType',
sort='day'
but I want to get reports from more than one channel and I can't figure out how to authorize more than one channel with oauth.
Authorization code:
SCOPES = ["https://www.googleapis.com/auth/yt-analytics.readonly"]
API_SERVICE_NAME = "youtubeAnalytics"
API_VERSION = "v2"
CLIENT_SECRETS_FILE = "client_secret_2.json"
def get_service():
flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
credentials = flow.run_local_server()
return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)