'How can I connect to the google search ads 360 api via a python script?

I have to build a data pipeline which downloads reports from google search ads 360, processes them and saves them in google big query. Because we're planning on migrating this to aws, it has to be done via python script which calls the sa 360 api. I have scoured the documentation and I can't find a programmatic way to make this api call. the only thing I've found is a way to get an access token manually by running an outdated python 2.7 script (https://developers.google.com/search-ads/v2/prereqs#install-sa360api.py). This script redirects you to a sign in page which the authorized google user has to click on in order for the script to receive an access token and a refresh token.

I was hoping that once I had this refresh token, I would be able to use it programatically every time I connect, but after attempting to get a new access token using this refresh token I got a mysterious "invalid_grant" error even though I replicated the get_refresh_token request from the sa360api.py script exactly. Having read up on this "invalid_grant" error it seems there are a number of causes, but I don't think I have met any of the criteria: (https://blog.timekit.io/google-oauth-invalid-grant-nightmare-and-how-to-fix-it-9f4efaf1da35).

Any help and examples would be much appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source