Can I check whether the logged-in user associated AdWords accounts to avoid AuthenticationError.NOT_ADS_USER?

49 views
Skip to first unread message

emag

unread,
Dec 28, 2018, 3:30:31 AM12/28/18
to AdWords API and Google Ads API Forum
Hi,

Can I check whether the logged-in user associated AdWords accounts for avoiding AuthenticationError.NOT_ADS_USER?

I'm using the following java library version.

* "com.google.api-ads" % "ads-lib"      % 4.1.0,
* "com.google.api-ads" % "adwords-axis" % 4.1.0,

My code snippet is here(Scala).

I would like to check if the user associated AdWords accounts before (1) invoking CustomerServiceInterface#getCustomers may throw com.google.api.ads.adwords.axis.v201806.cm.ApiException with AuthenticationError.NOT_ADS_USER.

import com.google.api.ads.adwords.axis.factory.AdWordsServices
import com.google.api.ads.adwords.axis.v201806.mcm.CustomerServiceInterface
import com.google.api.ads.adwords.lib.client.AdWordsSession
import com.google.api.ads.common.lib.auth.OfflineCredentials
import com.google.api.ads.common.lib.auth.OfflineCredentials.Api

val credential
= new OfflineCredentials.Builder()
 
.forApi(Api.ADWORDS)
 
.withRefreshToken(refreshToken)
 
.withClientSecrets(<from config>, <from config>)
 
.build()
 
.generateCredential()
)

val session
=
 
new AdWordsSession.Builder()
   
.withOAuth2Credential(credential)
   
.withDeveloperToken(<from config>)
   
.build()

val customerService
= AdWordsServices.getInstance().get(session, classOf[CustomerServiceInterface])

// (1)
customerService
.getCustomers


Thanks,

Yoshimasa

Milind Sankeshware (AdWords API Team)

unread,
Dec 28, 2018, 10:24:01 AM12/28/18
to AdWords API and Google Ads API Forum
Hi Yoshimasa,

The AuthenticationError.NOT_ADS_USER usually occurs when the login used to generate the access token is not associated with any AdWords account. Make sure to log in with a valid AdWords account (typically your manager account) for the OAuth flow. Please give it a try and let me know the user account/email id along with the client customer id you are trying to access if the problem persists. You can use 'Reply privately to author' option while responding.

Thanks,
Milind, AdWords API Team

emag

unread,
Dec 28, 2018, 11:28:10 AM12/28/18
to AdWords API and Google Ads API Forum
Hi Milind, thank you for your reply!

I'm sorry I didn't make it clear enough.

My application's users can log in with their Google account which is not associated with any AdWords account.

It's almost a human error but I can't find how to prevent it on OAuth flow.

So, I'm looking for any way to check the user whether or not is associated with any AdWords account.

Thanks!

Milind Sankeshware (AdWords API Team)

unread,
Dec 28, 2018, 3:09:42 PM12/28/18
to AdWords API and Google Ads API Forum
Hi Yoshimasa,

You can add the login email as a admin user in the AdWords account. To add the user, please follow the steps in this Help Center article. After adding the user the API call should work. If you are still facing an issue, I would suggest to create new OAuth credentials with the email which is associated with that AdWords account. Please refer to this steps to create the OAuth credentials.

Yoshimasa Tanabe

unread,
Jan 2, 2019, 11:46:43 PM1/2/19
to AdWords API and Google Ads API Forum
Hi Milind,

I want to know if we are on the same page. Is the following my understanding correct?

1. On OAuth flow, it's not possible to prevent the users not associated with any AdWords account from log-in/authorizing my application.
    * I can't edit the user info as you said because the users are not mine but my customer's.
2. Adwords API has no way to check whether or not the users are associated with any AdWords account

Marc Selman

unread,
Jan 3, 2019, 6:40:56 AM1/3/19
to AdWords API and Google Ads API Forum
After finishing the OAuth flow I perform a test call and when I get the NOT_ADS_USER error I show an error to the user that it's not a valid Google Ads account and don't store the OAuth tokens.

Op donderdag 3 januari 2019 05:46:43 UTC+1 schreef Yoshimasa Tanabe:

Milind Sankeshware (AdWords API Team)

unread,
Jan 3, 2019, 1:54:20 PM1/3/19
to AdWords API and Google Ads API Forum
Hi,

Please find my inline responses below:

1. On OAuth flow, it's not possible to prevent the users not associated with any AdWords account from log-in/authorizing my application.
You will be able to login to the Google API Console Credentials page and generate the OAuth credentials for a non-AdWords account. If the email is not associated, then the call will fail with the NOT_ADS_USER.

2. Adwords API has no way to check whether or not the users are associated with any AdWords account
You can use the CustomerService.getcustomers to check all the customers directly accessible by the user authenticating the call. To check the user emails in your AdWords account, you can check the 'Account Access'  tab under the 'Tool' option.

Could you please share the email address which you are authenticating the call along with client customer id so that I can assist you further? You can use 'Reply privately to author' option while responding.

Yoshimasa Tanabe

unread,
Jan 29, 2019, 7:18:03 AM1/29/19
to AdWords API and Google Ads API Forum
Hi,
 
Really sorry for late reply.

> Marc

The way you shared makes sense. We should not store/use the token from non-ads user. Thanks!

> Milind

Thanks, I'll send the email/client customer id.

---

Yoshimasa
Reply all
Reply to author
Forward
0 new messages