Automate refresh token

41 views
Skip to first unread message

Monty808

unread,
Apr 17, 2021, 8:25:02 AM4/17/21
to AdWords API and Google Ads API Forum
Hello Google

Please provide instructions how to use the refresh token.  I mean wow I have to generate a refresh token once a week. 

1) I run python3 generate_refresh_token.py --client_id really --client_secret wtf
2) This folow this link in. the browser

Log into the Google Account you use to access your AdWords account and go to the following URL: 

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=dfdf&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadwords&state=EdJA0p54Q6TipuNa&prompt=consent&access_type=offline


3) Paste the code

4) Get the refresbh token.


THIS DOES NOT SCALE!!!!!!


So how do I do this just once or automate this process.  Please provide clear docs on how to make it certain I dont have to do this again with the python api.  Below is how I connect.


CLIENT_ID = ''fgsfgsfg'        

CLIENT_SECRET = 'sdfsfsdf

 REFRESH_TOKEN = '1//0eX4gtRg-7ZPHwVCCthE5as'

   DEVELOPER_TOKEN = 'FTRkyQ'

    USER_AGENT ='None'

oauth2_client = oauth2.GoogleRefreshTokenClient(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN)

    #adwords_client = adwords.AdWordsClient(DEVELOPER_TOKEN, oauth2_client, USER_AGENT,client_customer_id=CUSTOMER_SERVICE_ID)

    adwords_client = adwords.AdWordsClient(DEVELOPER_TOKEN, oauth2_client, USER_AGENT,cache=googleads.common.ZeepServiceProxy.NO_CACHE)

    adwords_client.SetClientCustomerId(CUSTOMER_SERVICE_ID)


Reply all
Reply to author
Forward
0 new messages