Validating API Key / AdSense Management Reporting

229 views
Skip to first unread message

David

unread,
Feb 22, 2012, 6:19:49 AM2/22/12
to adsen...@googlegroups.com
Hi,

I'm trying to write a simple local windows program with C# that will download AdSense reporting daily so I can load the data into my db. I have almost no programming experience so I'm looking for the easiest way to do this.

I tried to validate my API Key was working by using the URL below but I keep getting a 401 unauthorized error when I replace YOUR_API_KEY with my key:

https://www.googleapis.com/adsense/v1/reports?startDate=2012-01-01&endDate=2012-02-01&pp=1&key={YOUR_API_KEY}

How do I validate my API Key? Are there any examples of using the AdSense Management API to get simple reporting using the API Key?

Thanks,

D

Silvano Luciani

unread,
Feb 22, 2012, 10:38:12 AM2/22/12
to AdSense API Forum
Hello David,

You can find the documentation for OAuth 2 authorization flows here:
http://code.google.com/apis/accounts/docs/OAuth2.html

From the use case that you describe I think you need one of these two
flows, the first one is for installed applications, the second one for
web applications:
http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html
http://code.google.com/apis/accounts/docs/OAuth2WebServer.html

Unfortunately we don't have examples of use in C#, but you can check
the Google APIs Client Library for .NET to see if you can use some of
the code from the project:
http://code.google.com/p/google-api-dotnet-client/

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

On Feb 22, 11:19 am, David <mesoanalyt...@gmail.com> wrote:
> Hi,
>
> I'm trying to write a simple local windows program with C# that will download AdSense reporting daily so I can load the data into my db.  I have almost no programming experience so I'm looking for the easiest way to do this.
>
> I tried to validate my API Key was working by using the URL below but I keep getting a 401 unauthorized error when I replace YOUR_API_KEY with my key:
>
> https://www.googleapis.com/adsense/v1/reports?startDate=2012-01-01&en...{YOUR_API_KEY}

David

unread,
Feb 27, 2012, 12:56:38 PM2/27/12
to adsen...@googlegroups.com
Thanks for the prompt response. 
 
Would you confirm that I cannot use the API key under the "Simple API Access" to access the API?

Silvano Luciani

unread,
Feb 28, 2012, 4:56:15 AM2/28/12
to AdSense API Forum
Hello David,

you can't use the key under "Simple API Access" because every request
that your application sends to the AdSense Management API must include
an authorization token:
http://code.google.com/apis/adsense/management/getting_started.html#requests

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

You will need to create
Reply all
Reply to author
Forward
0 new messages