Given that there might be some problems with AdSense cookie-based Site Authentication and Google App Engine, the easiest way to do AdSense Site Authentication with GAE seems to be using HTTP Basic access authentication.
This is a Django app which lets you grant AdSense access to your site using its Site Authentication feature.
Download
Installation
Replaceyourrandomkeyhere in these instructions with a randomly generated key of your choosing- Copy the
adsense_site_authdirectory into your project - In
settings.py, addadsense_site_auth.middleware.AdSenseSiteAuthMiddlewaretoMIDDLEWARE_CLASSESand add a new lineADSENSE_SITEAUTH_PASSWORD='yourrandomkeyhere' - In Site Authentication in your AdSense account, add a login with
- Authentication Method set to Plain Http (.htaccess)
- Attribute
usernameset toAdSense - Attribute
passwordset toyourrandomkeyhere
Usage
In your web application's views, request.adsense_site_authenticated will be set to True if the request is coming from AdSense's bot.
Caveat
I have only tested this using Google App Engine Helper for Django and the stock Google App Engine Django 0.96. Patches to fix problems in other environments/Django versions are greatly appreciated.
Feedback / Bug reports
Please give your feedback, report bugs or contribute patches on the Github project page.
