Hi,
I'm trying to test the AdWords API to learn about its features.
I couldn't figure out why I keep
getting AuthorizationError.USER_PERMISSION_DENIED error.
For example, I try to run CreateAccount.java in Java client library example
provided from AdWords.
Here are my steps:
1. I created a production MCC account and then get a "Developer Token"
2. I created a test MCC account and then get a new "Client ID" and "Client
Secret" from console. From this I got the "Refresh Token"
I put the "Developer Token" (from step #1 above), "Client ID" and "Client
Secret" to ads.properties.
3. For "user agent" values in ads.properties, I put in the name of the
"Project ID".
4. And for the "client customer id" values in ads.properties, I put the
test MCC account customer ID.
5. Then I try to run this below and got the
AuthorizationError.USER_PERMISSION_DENIED error.
I'm wondering if there's any step I'm missing or doing wrong.
Thank you in advance for the help.
Below is the code I'm trying to run. The exception is thrown on this line:
ManagedCustomerReturnValue result = managedCustomerService.mutate(operations
);
public class CreateAccount {
public static void main(String[] args) throws Exception {
// Generate a refreshable OAuth2 credential similar to a ClientLogin
token
// and can be used in place of a service account.
Credential oAuth2Credential = new OfflineCredentials.Builder()
.forApi(Api.ADWORDS)
.fromFile()
.build()
.generateCredential();
// Construct an AdWordsSession.
AdWordsSession session = new AdWordsSession.Builder()
.fromFile()
.withOAuth2Credential(oAuth2Credential)
.build();
AdWordsServices adWordsServices = new AdWordsServices();
runExample(adWordsServices, session);
}
public static void runExample(
AdWordsServices adWordsServices, AdWordsSession session) throws
Exception {
// Get the CampaignService.
ManagedCustomerServiceInterface managedCustomerService =
adWordsServices.get(session, ManagedCustomerServiceInterface.class);
// Create account.
ManagedCustomer customer = new ManagedCustomer();
customer.setName("Customer created with ManagedCustomerService on " +
new DateTime());
customer.setCurrencyCode("EUR");
customer.setDateTimeZone("Europe/London");
// Create operations.
ManagedCustomerOperation operation = new ManagedCustomerOperation();
operation.setOperand(customer);
operation.setOperator(Operator.ADD);
ManagedCustomerOperation[] operations = new ManagedCustomerOperation[] {
operation};
// Add account.
ManagedCustomerReturnValue result = managedCustomerService.mutate(
operations);
// Display accounts.
for (ManagedCustomer customerResult : result.getValue()) {
System.out.println("Account with customer ID \"" + customerResult.
getCustomerId()
+ "\" was created.");
}
}
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/4ec72011-bd61-4533-bf61-c70f4137a3bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.