Hi I am working with the Adwords API in java and I keep getting invalid developer token errors trying to use the sandbox. I pasted my code below with the credentials omitted. I have seen others post this but then they say they fixed it yet don't specify how... // Copyright 2008, Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
package com.google.api.adwords.demo; /** This code sample creates a new campaign with ad scheduling. */ import java.net.URL; import com.google.api.adwords.v12.AdSchedule; import com.google.api.adwords.v12.AdScheduleStatus; import com.google.api.adwords.v12.Campaign; import com.google.api.adwords.v12.CampaignInterface; import com.google.api.adwords.v12.CampaignServiceLocator; //import com.google.api.adwords.v12.CountryTargets; //import com.google.api.adwords.v12.ContentTargeting; import com.google.api.adwords.v12.DayOfWeek; import com.google.api.adwords.v12.GeoTarget; //import com.google.api.adwords.v12.LanguageTarget; import com.google.api.adwords.v12.SchedulingInterval; //import com.google.api.adwords.v12.BudgetPeriod; import com.google.api.adwords.lib.AdWordsUser; // This package is optional, but you need it if you want to log the content // of the requests and responses, which can be useful for debugging. import com.google.api.adwords.lib.AdWordsServiceLogger; import org.apache.axis.client.Stub; public class AddCampaign { // Provide AdWords login information. private static final String email = "[EMAIL PROTECTED]"; private static final String password = "xxxxxx"; private static final String clientEmail = "[EMAIL PROTECTED]"; //private static final String clientEmail = "client_1"+email; private static final String useragent = "MTI: AdWords API Java Sample Code"; private static final String developerToken = "[EMAIL PROTECTED] +USD"; private static final String applicationToken = "not_needed_for_sandbox"; // private static final String namespace = "https:// adwords.google.com/api/adwords/v12"; //use the sandbox private static final String namespace = "https://adwords.google.com/ api/adwords/v12"; public static void main(String[] args) { try { // Set up service connection. AdWordsServiceLogger.logToFile("myLogFile.txt"); CampaignInterface service = new CampaignServiceLocator().getCampaignService(); // Define SOAP headers. /*((Stub) service).setHeader(namespace, "email", email); ((Stub) service).setHeader(namespace, "password", password); ((Stub) service).setHeader(namespace, "clientEmail", clientEmail); ((Stub) service).setHeader(namespace, "useragent", useragent); ((Stub) service).setHeader(namespace, "developerToken", developerToken); ((Stub) service).setHeader(namespace, "applicationToken", applicationToken); */ AdWordsUser user = new AdWordsUser(); URL url = user.getAlternateUrl(); String chkEmail = user.getEmail(); String chkTok = user.getDeveloperToken(); // what have we here System.out.println(url); System.out.println(chkEmail); System.out.println(chkTok); //yeah thats what i thought... ((Stub) service).setHeader(namespace, "email", user.getEmail()); ((Stub) service).setHeader(namespace, "password", user.getPassword()); ((Stub) service).setHeader(namespace, "clientEmail", user.getClientEmail()); ((Stub) service).setHeader(namespace, "useragent", user.getUseragent()); ((Stub) service).setHeader(namespace, "developerToken", user.getDeveloperToken()); ((Stub) service).setHeader(namespace, "applicationToken", user.getApplicationToken()); ((Stub) service).setHeader(namespace, "alternateUrl", user.getAlternateUrl().toString()); // Create new campaign structure with ad scheduling set to show ads on // Monday, Wednesday, and Friday from 8:00am to 5:00pm. Each bid is // multiplied by 1.0. SchedulingInterval intervalMonday = new SchedulingInterval(); intervalMonday.setDay(DayOfWeek.Monday); intervalMonday.setEndHour(17); intervalMonday.setEndMinute(0); intervalMonday.setMultiplier(1.0); intervalMonday.setStartHour(8); intervalMonday.setStartMinute(0); SchedulingInterval intervalWednesday = new SchedulingInterval(); intervalWednesday.setDay(DayOfWeek.Wednesday); intervalWednesday.setEndHour(17); intervalWednesday.setEndMinute(0); intervalWednesday.setMultiplier(1.0); intervalWednesday.setStartHour(8); intervalWednesday.setStartMinute(0); SchedulingInterval intervalFriday = new SchedulingInterval(); intervalFriday.setDay(DayOfWeek.Friday); intervalFriday.setEndHour(17); intervalFriday.setEndMinute(0); intervalFriday.setMultiplier(1.0); intervalFriday.setStartHour(8); intervalFriday.setStartMinute(0); AdSchedule schedule = new AdSchedule(); schedule.setIntervals(new SchedulingInterval[] { intervalMonday, intervalWednesday, intervalFriday}); schedule.setStatus(AdScheduleStatus.Enabled); // Create new campaign structure. Campaign campaign = new Campaign(); campaign.setName("Sample Campaign"); campaign.setBudgetAmount(new Long(100000)); //campaign.setBudgetPeriod("Daily"); GeoTarget geoTargeting = new GeoTarget(); //geoTargeting.setCountryTargets(new CountryTargets(new String[] {"US"})); campaign.setGeoTargeting(geoTargeting); //LanguageTarget languageTargeting = new LanguageTarget(); //languageTargeting.setLanguages(new String[] {"en"}); //campaign.setLanguageTargeting(languageTargeting); campaign.setSchedule(schedule); // Add campaign. campaign = service.addCampaign(campaign); // Display new campaign. System.out.println("New campaign with name \"" + campaign.getName() + "\" and id \"" + campaign.getId() + "\" was created."); } catch(Exception e) { e.printStackTrace(); } } } the response i get from this is as follows: AxisFault faultCode: {http://schemas.xmlsoap.org/soap/ envelope/}Server.userException faultSubcode: faultString: The developer token is invalid. faultActor: faultNode: faultDetail: {https://adwords.google.com/api/adwords/v12}fault: <ns1:code>42</ns1:code> <ns1:message>The developer token is invalid.</ns1:message> <ns1:trigger>[EMAIL PROTECTED]</ns1:trigger> The developer token is invalid. ... imagine a long stack trace here ... and here is my SOAP log Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender invoke FINE: Enter: HTTPSender::invoke Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender writeToSocket FINE: XML sent: Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender writeToSocket FINE: --------------------------------------------------- Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender writeToSocket FINE: POST /api/adwords/v12/CampaignService HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/related, text/* User-Agent: Axis/1.2.1 Host: adwords.google.com Cache-Control: no-cache Pragma: no-cache SOAPAction: "" Content-Length: 2614 <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance"><soapenv:Header><ns1:email soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="https://adwords.google.com/api/ adwords/v12">[EMAIL PROTECTED]</ns1:email><ns2:password soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns2="https://adwords.google.com/api/ adwords/v12">xxxxxxx</ns2:password><ns3:clientEmail soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns3="https://adwords.google.com/api/ adwords/v12"/><ns4:useragent soapenv:actor="http://schemas.xmlsoap.org/ soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns4="https:// adwords.google.com/api/adwords/v12">MTI: Adwords API Testing</ ns4:useragent><ns5:developerToken soapenv:actor="http:// schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns5="https://adwords.google.com/api/adwords/ v12">[EMAIL PROTECTED]</ ns5:developerToken><ns6:applicationToken soapenv:actor="http:// schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns6="https://adwords.google.com/api/adwords/ v12">not_required_for_sandbox</ns6:applicationToken><ns7:alternateUrl soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns7="https://adwords.google.com/api/ adwords/v12">https://sandbox.google.com/</ns7:alternateUrl></ soapenv:Header><soapenv:Body><addCampaign xmlns="https:// adwords.google.com/api/adwords/v12"><campaign><budgetAmount>100000</ budgetAmount><budgetOptimizerSettings xsi:nil="true"/ ><contentTargeting xsi:nil="true"/><enableSeparateContentBids xsi:nil="true"/><geoTargeting><targetAll>false</targetAll></ geoTargeting><id>0</id><languageTargeting xsi:nil="true"/><name>Sample Campaign</name><networkTargeting xsi:nil="true"/ ><schedule><intervals><day>Monday</day><endHour>17</ endHour><endMinute>0</endMinute><multiplier>1.0</ multiplier><startHour>8</startHour><startMinute>0</startMinute></ intervals><intervals><day>Wednesday</day><endHour>17</ endHour><endMinute>0</endMinute><multiplier>1.0</ multiplier><startHour>8</startHour><startMinute>0</startMinute></ intervals><intervals><day>Friday</day><endHour>17</ endHour><endMinute>0</endMinute><multiplier>1.0</ multiplier><startHour>8</startHour><startMinute>0</startMinute></ intervals><status>Enabled</status></schedule><status xsi:nil="true"/></ campaign></addCampaign></soapenv:Body></soapenv:Envelope> Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: HTTP/1.0 500 Internal Server Error Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: Content-Type text/xml; charset=utf-8 Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: Date Tue, 28 Oct 2008 16:08:52 GMT Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: X-Content-Type-Options nosniff Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: Expires Tue, 28 Oct 2008 16:08:51 GMT Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: Cache-Control private, max-age=0 Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: Server GFE/1.3 Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readHeadersFromSocket FINE: Connection Close Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readFromSocket FINE: no Content-Length Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readFromSocket FINE: XML received: Oct 28, 2008 11:08:52 AM org.apache.axis.transport.http.HTTPSender readFromSocket FINE: ----------------------------------------------- Oct 28, 2008 11:08:53 AM org.apache.axis.transport.http.HTTPSender readFromSocket FINE: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server.userException</faultcode> <faultstring>The developer token is invalid.</faultstring> <detail> <ns1:fault xmlns:ns1="https://adwords.google.com/api/adwords/v12"> <ns1:code>42</ns1:code> <ns1:message>The developer token is invalid.</ns1:message> <ns1:trigger>[EMAIL PROTECTED]</ns1:trigger> </ns1:fault> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope> Oct 28, 2008 11:08:53 AM org.apache.axis.transport.http.HTTPSender invoke FINE: Exit: HTTPDispatchHandler::invoke and lastly the properties, set up per sandbox form. [EMAIL PROTECTED] password=xxxxxxxxx [EMAIL PROTECTED] useragent=MTI: Adwords API Testing [EMAIL PROTECTED] applicationToken=not_required_for_sandbox version=v12 alternateUrl=https://sandbox.google.com/ Just a recap- I am trying to use this to access the sandbox with sandbox alternate url, and sandbox style client. Thanks + take care- -Jeff --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en -~----------~----~----~----~------~----~------~--~---