'Must Authenticate' Problem using Blogger API on App Engine

70 views
Skip to first unread message

Murali

unread,
Sep 21, 2008, 10:24:59 PM9/21/08
to Google App Engine
Hi All,

I am trying to access GData Blogger API on App Engine.
Though ProgrammaticLogin() was successful, subsequent GetBlogFeed()
fails throwing the following error:

File "C:\xxx\src\gdata\blogger\service.py", line 40, in GetBlogFeed
return self.Get(uri, converter=gdata.blogger.BlogFeedFromString)
File "C:\xxx\src\gdata\service.py", line 703, in Get
'reason': server_response.reason, 'body': result_body}
RequestError: {'status': 401, 'body': 'Must authenticate to use
'default' user', 'reason': ''}

I am using gdata-py 1.2.1 and latest version of app engine sdk on
Windows Vista.
I have verified the email/password on blogger and everything works
fine. Even the ProgrammaticLogin() call was successful.

Here is the source code snippet:
---
gdataService = gdata.blogger.service.BloggerService()
gdata.alt.appengine.run_on_appengine(gdataService)

gdataService.email = 'email'
gdataService.password = 'password'
gdataService.source = 'SA01-PApp-1.0'
gdataService.service = 'blogger'
gdataService.account_type = 'GOOGLE'
gdataService.server = 'www.blogger.com'
gdataService.ProgrammaticLogin()

feed = gdataService.GetBlogFeed()
--
Has anybody tried to use blogger API on App engine and experience
similar problems?
Any help or pointers would be greatly appreciated.

Thank you so much,
Murali

Jeff S

unread,
Sep 23, 2008, 6:42:45 PM9/23/08
to Google App Engine
Hi Murali,

Your code should work if you are signed in to your app. Beginning in
1.2.1, the gdata-python-client library stores auth tokens in the
datastore, but only does so if they can be associated with the current
user. In most cases, you wouldn't want every user to be using the same
auth token, so the library will not store a token if it doesn't know
who it belongs to. It looks like you want every user to use the same
token here, so you can either sign in to your app, or use an in memory
token_store by adding:

gdataService = gdata.blogger.service.BloggerService()
gdata.alt.appengine.run_on_appengine(gdataService)
gdataService.token_store = atom.token_store.TokenStore()

Happy coding,

Jeff

Robert

unread,
Oct 8, 2008, 3:36:01 PM10/8/08
to Google App Engine
Hi,

Unfortunately I'm reading this message thread only now. I think that
the (otherwise pretty good!) GAE documentation on the use of the Data
APIs could/should better explain that

gdata.alt.appengine.run_on_appengine(gdataService)

also changes the token store of the gdataService. As an exercise I
made a little Facebook App (that runs on GAE and uses the Google
Calendar API). Hence this app has no need to authenticate the user as
a Google user. I'd figured out the token store "issue" by myself and
fixed it by changing the GData module, like this:

def run_on_appengine(gdata_service, use_engine_token_store=True):
gdata_service.http_client = AppEngineHttpClient()
if use_engine_token_store:
gdata_service.token_store = AppEngineTokenStore()
return gdata_service

So that I could pass "use_engine_token_store=False". This patch is
fine but needs to be applied whenever the library changes. Likewise
the suggestion by Jeff S may need to be slightly changed whenever the
gdataService "normal" token store is replaced/renamed.
Anyway in my opinion the most important thing is to document this
change in token store in the Note mentioned in step 2 of
http://code.google.com/appengine/articles/gdata.html. Thanks!

Robert

P.S. I blogged on my experiences on GAE so far at:
http://betweenthekeys.blogspot.com/2008/10/battling-platforms.html

On Sep 24, 1:42 am, Jeff S <j...@google.com> wrote:
> Hi Murali,
>
> Your code should work if you are signed in to your app. Beginning in
> 1.2.1, the gdata-python-client library stores auth tokens in the
> datastore, but only does so if they can be associated with the current
> user. In most cases, you wouldn't want every user to be using the same
> authtoken, so the library will notstoreatokenif it doesn't know
> who it belongs to. It looks like you want every user to use the sametokenhere, so you can either sign in to your app, or use an in memory

Jeff S

unread,
Oct 8, 2008, 6:52:28 PM10/8/08
to Google App Engine
Hi Robert,

Thank you for chiming in. This is an issue that I'm planning to
address in the next release of gdata-python-client. I wrote up a
design doc and passed it around to some of my coworkers and I'd also
like comments from the community. This Google Data APIs library is
open source after all :)

http://code.google.com/p/gdata-python-client/wiki/AuthOnAppEngine

Thank you,

Jeff

On Oct 8, 12:36 pm, Robert <rjaa...@gmail.com> wrote:
> Hi,
>
> Unfortunately I'm reading this message thread only now. I think that
> the (otherwise pretty good!) GAE documentation on the use of the Data
> APIs could/should better explain that
>
> gdata.alt.appengine.run_on_appengine(gdataService)
>
> also changes the token store of the gdataService. As an exercise I
> made a little Facebook App (that runs on GAE and uses the Google
> Calendar API). Hence this app has no need to authenticate the user as
> a Google user. I'd figured out the token store "issue" by myself and
> fixed it by changing the GData module, like this:
>
> def run_on_appengine(gdata_service, use_engine_token_store=True):
>   gdata_service.http_client = AppEngineHttpClient()
>   if use_engine_token_store:
>       gdata_service.token_store = AppEngineTokenStore()
>   return gdata_service
>
> So that I could pass "use_engine_token_store=False". This patch is
> fine but needs to be applied whenever the library changes. Likewise
> the suggestion by Jeff S may need to be slightly changed whenever the
> gdataService "normal" token store is replaced/renamed.
> Anyway in my opinion the most important thing is to document this
> change in token store in the Note mentioned in step 2 ofhttp://code.google.com/appengine/articles/gdata.html. Thanks!
Reply all
Reply to author
Forward
0 new messages