Hello Nick,

First of all, you don't need two project IDs for test and prod setup, 
project ID is per application so you can use the same one. It also doesn't 
need to belong to the same account as any MCC (but is can).

Second, I strongly recommend against using service accounts. It has very 
limited benefits comparing to normal flow and requires you to be a domain 
administrator.

As per error, you have authorized with a login that doesn't have an AdWords 
account associated with it. Make sure your key (or refresh token) belongs 
to the correct account (test MCC) and you specify clientCustomerId 
properly. The latter needs to be a target test account (not MCC) ID.


-Danial, AdWords API Team. 



On Friday, August 14, 2015 at 2:55:47 PM UTC+2, 
[email protected] wrote:
>
> I am trying to retrieve campaign data using a test adwords service account 
> via the Java client library. Despite being able to obtain a refresh token 
> the actual call to the CampaignService class throws exception with error 
> code:
>
> [AuthenticationError.NOT_ADS_USER @ ; trigger:'<null>']
>
> My setup is the following:
>
> 1. I have a production MCC Account set on [email protected]. On 
> this account, from Google Developer Console, I have created a new project 
> and then requested a developer token for this account which is currently in 
> status "Pending approval". I created a new Client ID from Google Developer 
> Console > API & auth > Credentials > OAuth2 and specified "Service Account" 
> for its type.  
>
> 2. I have created a secondary test MCC Account on 
> [email protected]. Just like before I created a new project from 
> Google Developer Console and created a new Client ID and selected the 
> Service Account Type. In Google Adwords page, under Accounts, I've added a 
> new test AdWords account under the test MCC account. This test AdWords 
> account does not have its own email (as does the test MCC Account) but is 
> linked under the test MCC account. 
>
> 3. I have added a dummy campaign for the test AdWords account (the one 
> linked under the test MCC account).
>
> 4. I have downloaded the private key file for the test MCC Account.
>
> The code that I am using to get the refresh Token is this:
>
>       GoogleCredential credential = new GoogleCredential.Builder()
>      .setTransport(httpTransport)
>           .setJsonFactory(JSON_FACTORY)
>           .setServiceAccountId(TEST_MCC_ACCOUNT_CLIENT_EMAIL)
>           .setServiceAccountScopes(Collections.singleton("
> https://www.googleapis.com/auth/adwords";))
>           .setServiceAccountPrivateKeyFromP12File(new 
> File(TEST_MCC_ACCOUNT_P12_FILE))
>           .build();
>
>        credential.refreshToken();
>       
>       return credential;
>
> The refresh token is retrieved with no errors (I can't tell though whether 
> it's indeed the correct refresh token).
>
> With this refresh token I'm running the following code to retrieve the 
> campaign:
>       
>        AdWordsSession session = new AdWordsSession.Builder()
>      .withDeveloperToken(DEVELOPER_TOKEN_OF_PROD_MCC_ACCOUNT)
>      .withUserAgent(PROJECT_ID_IN_TEST_MCC_ACCOUNT)
>      .withOAuth2Credential(credential)
>      .build();
>
>       AdWordsServices adWordsServices = new AdWordsServices();
>       
>       CampaignServiceInterface campaignService = 
> adWordsServices.get(session, CampaignServiceInterface.class);
>
>       // Create selector.
>       Selector selector = new Selector();
>       selector.setFields(new String[] {"Id", "Name"});
>
>       // Get all campaigns.
>       CampaignPage page = campaignService.get(selector);
>
> The last line, however throws the exception which I've mentioned:
>
> Exception in thread "main" AxisFault
>  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
>  faultSubcode: 
>  faultString: [AuthenticationError.NOT_ADS_USER @ ; trigger:'&lt;null&gt;']
>  faultActor: 
>  faultNode: 
>  faultDetail: 
> {https://adwords.google.com/api/adwords/cm/v201506}ApiExceptionFault:<message>[AuthenticationError.NOT_ADS_USER
>  
> @ ; 
> trigger:'&lt;null&gt;']</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors
>  
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xsi:type="AuthenticationError"><fieldPath/><trigger>&lt;null&gt;</trigger><errorString>AuthenticationError.NOT_ADS_USER</errorString><ApiError.Type>AuthenticationError</ApiError.Type><reason>NOT_ADS_USER</reason></errors>
>
> [AuthenticationError.NOT_ADS_USER @ ; trigger:'<null>']
>
> One variation which I have tried is to create a third AdWords account, 
> which has an email address ([email protected]) associated to 
> it, link it under the test MCC Account, and change the code which creates 
> the credential to include the call to setServiceAccountUser("
> [email protected]"). In this case the call to 
> credential.refreshToken() fails with an error message "401 Unauthorized". 
> I've also tried using setServiceAccountUser("[email protected]").
>
> I'm not sure what the problem might be, whether there's an issue with the 
> way the account hierarchy is structured, whether there's something missing 
> from the accounts themselves or whether it's even possible to use a test 
> service account to retrieve data. Some help would be greatly appreciated.
>
>  
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/d1c1e443-a323-417a-9b23-5a4126701b4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to