Hello Danial,

Thanks for your prompt reply.

"It also doesn't need to belong to the same account as any MCC (but is can)"

1. I'm a little confused by what the account setup should be following this 
remark. My aim is to create a set-up that enables a test service account to 
retrieve campaign data. According to the documentation, the project created 
on Google Developer Console 
"is a collection of settings, credentials, and metadata about the 
application or applications you're working on that make use of Google 
Developer APIs and Google Cloud resources", so it does make sense to have a 
single Project ID for multiple applications which make access of Google 
Developer API. 

What I do not understand though is how is the association / link between 
the Google Developer Console and the (MCC or non-MCC) account on Google 
AdWords made? All they have in common is the Google Account on which they 
have been set up. For other API endpoints, I've noticed one can enable them 
from the Enable APIs section of GDC, but there's nothing like that for 
AdWords.

2. Could you give me an example of an account set-up for a test example 
using an Service Account? I'm only interested in the hierarchical 
structure. 

3. Should the client customer ID be the 10 digits one displayed under an 
AdWords account?

My apologies if all these seem like basic questions but it's my first time 
using AdWords and I'm trying to understand how it works rather than just 
find the fix. 

Many thanks,
Nick.



On Friday, August 14, 2015 at 3:55:47 PM UTC+3, 
[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/0e42a181-2e87-4824-b8c2-ec4b328d4950%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to