Digg API: User-Agent required

27 views
Skip to first unread message

arantius

unread,
Apr 21, 2009, 11:31:29 AM4/21/09
to Google App Engine
If I make a call to the Digg API like:

from google.appengine.api.urlfetch import fetch
url='http://services.digg.com/url/short/%s?appkey=http%
%3A//...appspot.com/' % token
result=fetch(url, follow_redirects=False)

Then the result is:

<?xml version="1.0" encoding="UTF-8"?>
<error code="1029" message="HTTP User-Agent header required"
timestamp="1240327450"/>

Sniffing the wire, I can see the outgoing request is:

GET /url/short/d1nYVs?appkey=http%3A//...appspot.com/ HTTP/1.1
Accept-Encoding: identity
Host: services.digg.com
Accept: */*

Indeed, no User-Agent header is provided. Attempting to specify one
myself does not work. This is only, yet, with the SDK.

Nick Johnson

unread,
Apr 22, 2009, 5:14:47 AM4/22/09
to google-a...@googlegroups.com
Hi,

This is a known issue with sites that check user-agent headers. By
design, Google App Engine does not allow you to specify your own
user-agent header. In production, a user-agent specifying the source
of the request is automatically added. The behaviour you're seeing in
the SDK is added to replicate this.

Unfortunately, the only way around this is to petition digg and other
providers that do User-agent checks to provide an alternate way of
identifying yourself.

-Nick Johnson

KARTHIKEYAN

unread,
Apr 22, 2009, 5:26:18 AM4/22/09
to google-a...@googlegroups.com

arantius

unread,
Apr 23, 2009, 1:52:37 PM4/23/09
to Google App Engine
On Apr 22, 5:14 am, Nick Johnson <nick.john...@google.com> wrote:
> .. In production, a user-agent specifying the source
> of the request is automatically added. The behaviour you're seeing in
> the SDK is added to replicate this.

I'm not seeing any behavior, however. There is _no_ user agent header
in the request from the SDK.

Nick Johnson

unread,
Apr 23, 2009, 2:00:34 PM4/23/09
to google-a...@googlegroups.com
You're right - I was mistaken. However, good news! 1.2.1 just came
out, and you can now set user agent headers for URLFetch. See
http://code.google.com/p/googleappengine/wiki/SdkReleaseNotes for more
details.

-Nick Johnson

arantius

unread,
Apr 23, 2009, 4:10:15 PM4/23/09
to Google App Engine
On Apr 23, 2:00 pm, Nick Johnson <nick.john...@google.com> wrote:
> .. good news! 1.2.1 just came
> out, and you can now set user agent headers for URLFetch...

What timing! Thanks =)
Reply all
Reply to author
Forward
0 new messages