I am trying to get access to my brand account's Youtube reporting data programmatically via delegated service account credentials and having some real trouble figuring out how to do it.
So far, I've been successfully able to run delegated API requests without onBehalfOfContentOnwer being supplied (i.e. returns correct data for that account), so I know that service account delegation is viable and configured properly. But when trying to get data for the content owner with onBehalfOfContentOnwer that the delegation account has access to, I get the error below.
I have also verified that my delegation email address does indeed have access to query the brand account's data programmatically as have been able to successfully make requests to the content owner's / brand account's data with the "Try it yourself" section of the Youtube docs and in the oauth playground. Is there a way to build a token with respect to the desired brand account? Or something else I am missing?
from google.oauth2 import service_accountimport googleapiclient.discoverySCOPES = ['https://www.googleapis.com/auth/youtube', 'https://www.googleapis.com/auth/yt-analytics-monetary.readonly','https://www.googleapis.com/auth/yt-analytics.readonly']credentials = service_account.Credentials.from_service_account_info( service_account_cred, scopes=SCOPES, subject='myemail@mycompany.com' )credentials.refresh( google.auth.transport.requests.Request())youtube_reporting = googleapiclient.discovery.build('youtubereporting', 'v1', credentials=credentials)print(youtube_reporting.reportTypes().list(onBehalfOfContentOwner='mycontentownerid').execute())googleapiclient.errors.HttpError: <HttpError 403 when requesting https://youtubereporting.googleapis.com/v1/reportTypes?onBehalfOfContentOwner=mycontentownerid&alt=json returned "The caller does not have permission". Details: "The caller does not have permission">