I have a content owner account, and I used Google's API Explorer to figure out the query that I need to send. My problem now is that I can't figure out how to send that same query programmatically via Python. I have generated oauth credentials as well as an API key - for an installed application -, so I also have a client_secrets.json
file. What I can't figure out is how do I use this information to get through and send my query. There's a lot of talk of "scope" in the other questions I've reviewed, but I'm confused about how I need to include that in my request.
I tried passing the contents of the client secrets file as headers in my request, I also tried just appending the simple API key to the end of the request, no dice. Also looked at several questions on here, but they either aren't relevant to content owners, or are about getting the right query itself rather than the authentication portion. Any help would be appreciated. Thanks in advance!
Examples:
yt_headers = {"client_id": CLIENT_ID,
"client_secret":CLIENT_SECRET,
"redirect_uris": REDIRECT_URIS,
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token"}
query_string = 'https://www.googleapis.com/youtube/analytics/v1/reports?ids=contentOwner%3D%3DCONTENT_ID&start-date=2015-09-28&end-date=2015-11-05&metrics=views&dimensions=insightTrafficSourceType&filters=video%3D%3DVIDEO_ID&fields=rows'
api_request = http.request('GET', query_string, headers=yt_headers)