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 prod_mcc_em...@domain.com. 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 test_mcc_em...@domain.com. 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:'<null>'] faultActor: faultNode: faultDetail: {https://adwords.google.com/api/adwords/cm/v201506}ApiExceptionFault:<message>[AuthenticationError.NOT_ADS_USER @ ; trigger:'<null>']</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AuthenticationError"><fieldPath/><trigger><null></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 (test_adwords_em...@domain.com) associated to it, link it under the test MCC Account, and change the code which creates the credential to include the call to setServiceAccountUser("test_adwords_em...@domain.com"). In this case the call to credential.refreshToken() fails with an error message "401 Unauthorized". I've also tried using setServiceAccountUser("test_mcc_em...@domain.com"). 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 adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com 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 adwords-api+unsubscr...@googlegroups.com. 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/cd00cef3-df1c-4930-8b54-d15754e70e01%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.