I am trying (with not much luck) to access the Google AdWords API using the 
.Net 
Client Library <http://code.google.com/p/google-api-adwords-dotnet/> to 
access their SandBox <http://code.google.com/apis/adwords/docs/sandbox.html>API.

Here is my code:-


            // create campaign
            var campaign = new Campaign
                               {
                                   name = "Simon's Campaign",
                                   status = CampaignStatus.ACTIVE,
                                   servingStatus = ServingStatus.SERVING,
                                   budget = new Budget
                                                {
                                                    period = 
BudgetBudgetPeriod.DAILY,
                                                    amount = new Money
                                                                 {
                                                                    
 microAmount = 100000
                                                                 },
                                                    deliveryMethod = 
BudgetBudgetDeliveryMethod.STANDARD
                                                },
                                   adServingOptimizationStatus = 
AdServingOptimizationStatus.OPTIMIZE,
                                   frequencyCap = new FrequencyCap
                                                      {
                                                          impressions = 
100000,
                                                          timeUnit = 
TimeUnit.MINUTE,
                                                          level = 
Level.CAMPAIGN
                                                      }
                               };
            var operation = new CampaignOperation {@operator = 
Operator.ADD, operand = campaign};
            var operations = new CampaignOperation[1];
            operations[0] = operation;


            // get service
            var user = new AdWordsUser();
            var url = Request.Url.GetLeftPart(UriPartial.Path);
            var config = user.Config as AdWordsAppConfig;
            user.OAuthProvider = new AdsOAuthNetProvider(
                    config.OAuthConsumerKey,
                    config.OAuthConsumerSecret,
                    AdWordsService.GetOAuthScope(user.Config as 
AdWordsAppConfig),
                    url,
                    Session.SessionID
                );

            var service = (CampaignService) 
user.GetService(AdWordsService.v201109.CampaignService);
            var page = service.mutate(operations);

When I run this I get an `AdWordsApiException` with an InnerException 
`AuthenticationError.OAUTH_TOKEN_HEADER_INVALID @ 
 Service[CampaignService.mutate]`

Now I have the following in my `Web.config`:-

    <!-- Note: For testing purposes, you can use the OAuth consumer 
key/secret as anonymous/anonymous.-->
    <add key="AuthorizationMethod" value="OAuth"/>
    <add key="OAuthConsumerKey" value="anonymous"/>
    <add key="OAuthConsumerSecret" value="anonymous"/>
    <!-- Uncomment this key if you want to use v13 sandbox. -->
    <!-- <add key="LegacyAdWordsApi.Server" 
value="https://sandbox.google.com"/> -->
    <!-- Uncomment this key if you want to use AdWords API sandbox. -->
    <add key="AdWordsApi.Server" 
value="https://adwords-sandbox.google.com"/>

As I understand it this is set up correctly, what am I missing?

Any help would be very gratefully received!!!

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 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

Reply via email to