The api error:
[ApiUsageError.INVALID_CLIENT_EMAIL @ selector; trigger:'[here it prints 
the email of the MCC Account]']

Inside adwords.properties file:

email=[here the email of the MCC Account]
password=[here the password of the MCC Account]
clientId=[here the id of the Test Account]
useragent=JavaAdWordsApplication
developerToken=[our developer token]
partialFailure=false

The corresponding code:
//in a class where we authenticate the user:
public static long authenticateUser(String username, String password) 
throws IOException{
        AdWordsUser awu = ServiceRequest.getAdwordsAccount();
        
        if(awu != null)
            return ServiceRequest.getClientCustomerId(awu);
        return 0;
}

//inside the ServiceRequest class:
    public static AdWordsUser getAdwordsAccount() {
        if (user == null ) {
            try {
                // Log SOAP XML request and response.
                AdWordsServiceLogger.log();
                user = new AdWordsUser().generateClientAdWordsUser(null); 
// Get AdWordsUser from "~/adwords.properties".
            } catch (IOException e) {
                SystemMain.LOG.fatal("Problem with 'adwords.properties' 
file.");
                e.printStackTrace();
            }
        }
        return user;
}

public static long getClientCustomerId(AdWordsUser awu){
        
        try {
              AdWordsServiceLogger.log();

              AdWordsUser user = awu;

              InfoServiceInterface infoService = 
user.getService(AdWordsService.V201209.INFO_SERVICE);
              
              System.out.println("email: " + user.getEmail()); //here it 
just prints the MCC Account email
              String[] clientEmails = new String[] {user.getEmail()};

              // Create selector.
              InfoSelector selector = new InfoSelector();
              selector.setApiUsageType(ApiUsageType.UNIT_COUNT_FOR_CLIENTS);
              String today = new SimpleDateFormat("yyyyMMdd").format(new 
Date());
              selector.setDateRange(new DateRange(today, today));
              selector.setClientEmails(clientEmails);
              selector.setIncludeSubAccounts(true);

              // Get api usage info.
              ApiUsageInfo apiUsageInfo = infoService.get(selector);
              for (ApiUsageRecord record : 
apiUsageInfo.getApiUsageRecords()) {
                return record.getClientCustomerId();
              }
        } catch (Exception e) {
              e.printStackTrace();
        }
        
        return 0;
    }

On Saturday, November 24, 2012 11:19:24 PM UTC+1, Ewan Heming wrote:
>
> Hi Stamatina,
>
> The credentials you're sending sound correct, so maybe the problem is 
> somewhere else. Could you post the code you're using in case there's a 
> problem with it?
>
> Thanks,
>
> Ewan
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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



Reply via email to