I've got a Python script to connect data from DV360 to Google Sheets by using the StarThinker framework. The script was running correctly until a few weeks ago when the work email account of the person who set this up (Python Script, Google Cloud Project, Credential files) was decommissioned as he left the organization.
The Python script has 3 instances:
- Clear out a specific spreadsheet
- StarThinker instance
- Insert data into the spreadsheet
This is the StarThinker instance which is the one flagging the error (RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})
#DV360 Report to Google Sheet
!pip3 install git+https://github.com/google/starthinker
!pip3 install starthinker
from starthinker.util.configuration import Configuration
CONFIG = Configuration(
project="has-apac-prd-has-nz",
client="client.json",
service= "service.json",
user="user.json",
verbose=True
)
FIELDS = {
'auth_read':'user', # Credentials used for reading data.
'report_id':'1037961641', # DV360 report ID given in UI, not needed if name used.
'report_name':'dv360-to-sheet', # Name of report, not needed if ID used.
'sheet':'https://docs.google.com/spreadsheets/d/1CfqCANbSpm_40DQ1-Sm7oekboYNsFtzcYeZSnqhdPrk/edit#gid=0', # Full URL to sheet being written to.
'tab':'Sheet1', # Existing tab in sheet to write to.
}
print("Parameters Set To: %s" % FIELDS)
from starthinker.util.configuration import execute
from starthinker.util.recipe import json_set_fields
TASKS = [
{
'dbm':{
'auth':{'field':{'name':'auth_read','kind':'authentication','order':1,'default':'user','description':'Credentials used for reading data.'}},
'report':{
'report_id':{'field':{'name':'report_id','kind':'integer','order':1,'default':'','description':'DV360 report ID given in UI, not needed if name used.'}},
'name':{'field':{'name':'report_name','kind':'string','order':2,'default':'','description':'Name of report, not needed if ID used.'}}
},
'out':{
'sheets':{
'sheet':{'field':{'name':'sheet','kind':'string','order':3,'default':'','description':'Full URL to sheet being written to.'}},
'tab':{'field':{'name':'tab','kind':'string','order':4,'default':'','description':'Existing tab in sheet to write to.'}},
'range':'A1'
}
}
}
}
]
json_set_fields(TASKS, FIELDS)
execute(CONFIG, TASKS, force=True)
Here some stuff I've already done:
- Created a new report on DV360 under my user
- Made sure to have all accesses to DV360 and the spreadsheet
- Made sure to have permission for the Google Cloud project
- Gave me permission to the star thinker service account.
- Created a new client and new service account within GCP and placed these files into the same folder with the python script (made sure to change the name of the files in the script).
Also, when I try to open this URL I see the invalid request issue like below https://accounts.google.com/signin/oauth/error/v2
To finish, there are x3 json files placed in the same folder as the script:
- service.json
- client.json
- user.json
I was able to re-create the first two on Google Cloud (as mentioned above), but couldn't find a way to re-create user.json which I think might be the main issue here.
I would really appreciate some help on this.
Thanks.