Reputation: 101
I use the following python function to mark an item as read in google reader, but it always returns error HTTPErrors: HTTP 401: Unauthorized:
def mark_as_read(SID, entryid): token = get_token(SID) mark_as_read_url = 'http://www.google.com/reader/api/0/edit-tag' header = {'Content-type': 'application/x-www-form-urlencoded'} post_data = urllib.urlencode({ 'i': entryid, 'a': 'user/-/state/com.google/read', 'ac': 'edit', 'T': token }) request = urllib2.Request(mark_as_read_url, post_data, header) f = urllib2.urlopen(request) result = f.read()
Other functions are successfully retrieving feeds and entries , so it's not something basic like a wrong username or password. I've read that urlencoding is required, so I've done that. A sample entryid looks like this: tag:google.com,2005:reader/item/f66ad0fb64f56a22
What am I doing wrong?
Upvotes: 7
Views: 1158
Reputation: 1018
It seems you are missing the authentication header:
header = {
'Content-type': 'application/x-www-form-urlencoded',
'Authorization': 'GoogleLogin auth=YOUR_AUTH_TOKEN'
}
Upvotes: 2
Reputation: 4055
When i compare this to the request I'm making in Firefox (inspected with liveheaders), it looks ok. I only have the extra parameters
async=true
sync=true
s=feed/http://feeds.feedburner.com/37signals/beM
And in the user, on the place of -
there is a long id.
So you could try adding the two sync parameters, adding the s parameter, and filling in an id for the -
.
With regard to the urlencoding you're doing, that seems to be ok.
Upvotes: 0