I am trying to grab a Gmail atom feed from a python application using OAuth. I have a working application that downloads the Google Reader feed, and I think it's just a matter of changing the scope and URL of the feed. After replacing the URLs, I can still successfully get the Request and Access tokens, but when I try to grab the feed using the access token, I get the "401 Unauthorized" error. Here is my simple test program:
import urlparse import oauth2 as oauth scope = "https://mail.google.com/mail/feed/atom/" sub_url = scope + "unread" request_token_url = "https://www.google.com/accounts/OAuthGetRequestToken?scope=%s&xoauth_displayname=%s" % (scope, "Test Application") authorize_url = 'https://www.google.com/accounts/OAuthAuthorizeToken' access_token_url = 'https://www.google.com/accounts/OAuthGetAccessToken' oauth_key = "anonymous" oauth_secret = "anonymous" consumer = oauth.Consumer(oauth_key, oauth_secret) client = oauth.Client(consumer)
You will notice that I use "anonymous / anonymous" as my OAuth key / secret, as stated in Google docs for unregistered applications . This works great for a Google reader, so I see no reason why it shouldn't work in Gmail. Does anyone have an idea why this might not work, or how can I solve the problem? Thanks.
python oauth gmail gdata
Will
source share