Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I mark an item as read with google reader api (using python)

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?

like image 885
Ned Ryerson Avatar asked Nov 08 '09 06:11

Ned Ryerson


1 Answers

It seems you are missing the authentication header:

header = {
    'Content-type': 'application/x-www-form-urlencoded',
    'Authorization': 'GoogleLogin auth=YOUR_AUTH_TOKEN'
}
like image 58
coryjacobsen Avatar answered Oct 01 '22 18:10

coryjacobsen