Do I need to authenticate for gmb api every time?

19 views
Skip to first unread message

Jiaxin Wu

unread,
Nov 4, 2019, 10:05:07 AM11/4/19
to AdWords API and Google Ads API Forum
Hi, 
The first step for linking business locations to Google ads campaign is to authenticate for GMB and AdWords API calls then generate access_token. I create locations for our client accounts in our own gmb account and use the location to create location extensions. 
I'm using the following scope to create authentication url:

var auth_url = Auth.oauth2Client.generateAuthUrl({
        access_type
: 'offline',
        prompt      
: 'consent',
        scope      
: [
           
'https://www.googleapis.com/auth/adwords',
           
'https://www.googleapis.com/auth/plus.business.manage',
           
'https://www.googleapis.com/auth/business.manage'
       
]
   
});


Every time I test on my test account, gmb api ask me to do the authentication step to generate a new access_token, or I can't access gmb api. In order to get the access_token I need to give permission on the consent page. But our google adwords mcc account contains many client accounts. It is impossible to generate a new access token every time clients want to create new campaign with location extension, cause our code is already on production. 
Is there any way that I can generate a access token with longer expire time that I can refresh it once a month?

Thanks!

Google Ads API Forum Advisor Prod

unread,
Nov 4, 2019, 4:05:34 PM11/4/19
to jiaxi...@gmail.com, adwor...@googlegroups.com
Hello Jiaxin,

I am form the Google Ads API team. If you are using our client libraries they will take care of refreshing the access token using the refresh token. You could refer here to create a refresh token which usually lasts for years. Please give it a try and let me know if you have any further questions.

Regards,
Sai Teja, Google Ads API Team

ref:_00D1U1174p._5001UMW9Ng:ref
Reply all
Reply to author
Forward
0 new messages