Does ProgrammaticLogin works in a Google App Engine Task?

17 views
Skip to first unread message

Michelschr

unread,
Oct 21, 2009, 10:11:31 AM10/21/09
to GData Python Client Library Contributors
Hello everyone,

The following code works fine in Google App Engine when it is part of
a normal request (not a task):

spreadKey = '...'

client = gdata.spreadsheet.service.SpreadsheetsService()
gdata.alt.appengine.run_on_appengine(client)
client.email = 'anA...@gmail.com'
client.password = '...'
client.source = '...'
client.ProgrammaticLogin()

feed = client.GetWorksheetsFeed(spreadKey) #

When I invoke it within a task, I receive this error:

Exception in request: RequestError: {'status': 404L, 'body': '<HTML>
\n<HEAD>\n<TITLE>Not Found</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF"
TEXT="#000000">\n<H1>Not Found</H1>\n<H2>Error 404</H2>\n</BODY>\n</
HTML>\n', 'reason': ''}
Traceback (most recent call last):
File "/base/python_lib/versions/third_party/django-1.0/django/core/
handlers/base.py", line 86, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/base/data/home/apps/.../..._views.py", line 412, in ...
feed = client.GetWorksheetsFeed(spreadKey) #
File "/base/data/home/.../gdata/spreadsheet/service.py", line 126,
in GetWorksheetsFeed
converter=gdata.spreadsheet.SpreadsheetsWorksheetsFeedFromString)
File "/base/data/home/.../gdata/service.py", line 1050, in Get
'reason': server_response.reason, 'body': result_body}
RequestError: {'status': 404L, 'body': '<HTML>\n<HEAD>\n<TITLE>Not
Found</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
\n<H1>Not Found</H1>\n<H2>Error 404</H2>\n</BODY>\n</HTML>\n',
'reason': ''}

I need to access consecutively:
feed = client.GetWorksheetsFeed(spreadKey) and
listFeed = client.GetListFeed(spreadKey, workKey)

for a spreadsheet of a user which give me access to only this
spreadsheet. I try to use ProgrammaticLogin so that the user can grant
access to 'anA...@gmail.com'. (And that works fine, but not in a
task...)

Previously I tried to use the AuthSub interface as explained in a
previous tread (
http://groups.google.com/group/gdata-python-client-library-contributors/browse_thread/thread/bf36857e9be98899?hl=en
), but with this method, I had problems to limit the scope of the
authorization to only one spreadsheet...?

Could someone help me to find a way to solve this situation?

Thanks in advance,

Michel

Tim Garthwaite

unread,
Oct 21, 2009, 10:26:18 AM10/21/09
to gdata-python-client-...@googlegroups.com

You really had a hard time setting the scope in AuthSub?  If you look down further into the thread, someone provides an example of explicitly setting the scope to a specific feed.  Also, you can specify more than one URL in the scope, simply by listing them all in one string, separated by spaces.

Tim Garthwaite
+1 401-405-1513
Appirio: Accelerating Enterprise Adoption of the Cloud
www.appirio.com

Michelschr

unread,
Oct 21, 2009, 10:43:56 AM10/21/09
to GData Python Client Library Contributors
Thanks for your answer...

Yes I still have a hard time setting the scope!

As I explained in the other thread, I had success with:
scope = 'http://spreadsheets.google.com/feeds/list/' + key + '/' +
worksheetId + '/private/full'

But it does'nt work with
scope = http://spreadsheets.google.com/feeds/worksheets/<spreadSheetKey>/private/full
when I tried to have access to the feed = client.GetWorksheetsFeed
(spreadSheetKey)!

Anyway... It seems that this should be a better direction when I read
that ClientLogin is only for "installed applications and "Web
applications should not use this authorization method..." in
http://code.google.com/intl/fr/apis/accounts/docs/AuthForInstalledApps.html

Thus, I still have a hard time...

On Oct 21, 4:26 pm, Tim Garthwaite <t...@appirio.com> wrote:
> You really had a hard time setting the scope in AuthSub?  If you look down
> further into the thread, someone provides an example of explicitly setting
> the scope to a specific feed.  Also, you can specify more than one URL in
> the scope, simply by listing them all in one string, separated by spaces.
>
> Tim Garthwaite
> +1 401-405-1513
> Appirio: Accelerating Enterprise Adoption of the Cloudwww.appirio.com
>
> On Wed, Oct 21, 2009 at 9:11 AM, Michelschr <michels...@gmail.com> wrote:
>
> > Hello everyone,
>
> > The following code works fine in Google App Engine when it is part of
> > a normal request (not a task):
>
> >    spreadKey = '...'
>
> >    client     = gdata.spreadsheet.service.SpreadsheetsService()
> >    gdata.alt.appengine.run_on_appengine(client)
> >    client.email    = 'anAd...@gmail.com'
> > access to 'anAd...@gmail.com'. (And that works fine, but not in a
> > task...)
>
> > Previously I tried to use the AuthSub interface as explained in a
> > previous tread (
>
> >http://groups.google.com/group/gdata-python-client-library-contributo...

Michelschr

unread,
Oct 21, 2009, 11:08:52 AM10/21/09
to GData Python Client Library Contributors
Some precisions:

1. It is important for me that this reading of the spreadsheet happens
in a task, thus with no contact with the user, that is why I first
looked at the ProgrammaticLogin. (With AuthSub, is it a way to
transfer the token to a particular asynchronous task?)

2. The ProgrammaticLogin doesn't work either with:
listFeed = client.GetListFeed(spreadKey, workKey)


On Oct 21, 4:43 pm, Michelschr <michels...@gmail.com> wrote:
> Thanks for your answer...
>
> Yes I still have a hard time setting the scope!
>
> As I explained in the other thread, I had success with:
> scope = 'http://spreadsheets.google.com/feeds/list/'+ key + '/' +
> worksheetId + '/private/full'
>
> But it does'nt work with
> scope =http://spreadsheets.google.com/feeds/worksheets/<spreadSheetKey>/private/full
> when I tried to have access to the feed = client.GetWorksheetsFeed
> (spreadSheetKey)!
>
> Anyway... It seems that this should be a better direction when I read
> that ClientLogin is only for "installed applications and "Web
> applications should not use this authorization method..." inhttp://code.google.com/intl/fr/apis/accounts/docs/AuthForInstalledApp...

Michelschr

unread,
Oct 21, 2009, 11:09:06 AM10/21/09
to GData Python Client Library Contributors
Some precisions:

1. It is important for me that this reading of the spreadsheet happens
in a task, thus with no contact with the user, that is why I first
looked at the ProgrammaticLogin. (With AuthSub, is it a way to
transfer the token to a particular asynchronous task?)

2. The ProgrammaticLogin doesn't work either with:
listFeed = client.GetListFeed(spreadKey, workKey)


On Oct 21, 4:43 pm, Michelschr <michels...@gmail.com> wrote:
> Thanks for your answer...
>
> Yes I still have a hard time setting the scope!
>
> As I explained in the other thread, I had success with:
> scope = 'http://spreadsheets.google.com/feeds/list/'+ key + '/' +
> worksheetId + '/private/full'
>
> But it does'nt work with
> scope =http://spreadsheets.google.com/feeds/worksheets/<spreadSheetKey>/private/full
> when I tried to have access to the feed = client.GetWorksheetsFeed
> (spreadSheetKey)!
>
> Anyway... It seems that this should be a better direction when I read
> that ClientLogin is only for "installed applications and "Web
> applications should not use this authorization method..." inhttp://code.google.com/intl/fr/apis/accounts/docs/AuthForInstalledApp...

Michelschr

unread,
Oct 21, 2009, 11:09:14 AM10/21/09
to GData Python Client Library Contributors
Some precisions:

1. It is important for me that this reading of the spreadsheet happens
in a task, thus with no contact with the user, that is why I first
looked at the ProgrammaticLogin. (With AuthSub, is it a way to
transfer the token to a particular asynchronous task?)

2. The ProgrammaticLogin doesn't work either with:
listFeed = client.GetListFeed(spreadKey, workKey)


On Oct 21, 4:43 pm, Michelschr <michels...@gmail.com> wrote:
> Thanks for your answer...
>
> Yes I still have a hard time setting the scope!
>
> As I explained in the other thread, I had success with:
> scope = 'http://spreadsheets.google.com/feeds/list/'+ key + '/' +
> worksheetId + '/private/full'
>
> But it does'nt work with
> scope =http://spreadsheets.google.com/feeds/worksheets/<spreadSheetKey>/private/full
> when I tried to have access to the feed = client.GetWorksheetsFeed
> (spreadSheetKey)!
>
> Anyway... It seems that this should be a better direction when I read
> that ClientLogin is only for "installed applications and "Web
> applications should not use this authorization method..." inhttp://code.google.com/intl/fr/apis/accounts/docs/AuthForInstalledApp...

Tim Garthwaite

unread,
Oct 21, 2009, 11:13:46 AM10/21/09
to gdata-python-client-...@googlegroups.com

Another thing you may want to try is to use the (3-legged, i.e. not special admin priv) OAuth method of authentication.  It is my understanding that both ClientLogin and AuthSub are to be depracated in favor of AuthSub, and if the worksheet scope works out better there, you should be all set.

:-)

Tim Garthwaite
+1 401-405-1513
Appirio: Accelerating Enterprise Adoption of the Cloud
www.appirio.com


Michelschr

unread,
Oct 21, 2009, 11:19:15 AM10/21/09
to GData Python Client Library Contributors
Thanks a lot, I will investigate in this direction...

On Oct 21, 5:13 pm, Tim Garthwaite <t...@appirio.com> wrote:
> Another thing you may want to try is to use the (3-legged, i.e. not special
> admin priv) OAuth method of authentication.  It is my understanding that
> both ClientLogin and AuthSub are to be depracated in favor of AuthSub, and
> if the worksheet scope works out better there, you should be all set.
> :-)
>
> Tim Garthwaite
> +1 401-405-1513
> Appirio: Accelerating Enterprise Adoption of the Cloudwww.appirio.com
>
> On Wed, Oct 21, 2009 at 10:09 AM, Michelschr <michels...@gmail.com> wrote:
>
> > Some precisions:
>
> > 1. It is important for me that this reading of the spreadsheet happens
> > in a task, thus with no contact with the user, that is why I first
> > looked at the ProgrammaticLogin. (With AuthSub, is it a way to
> > transfer the token to a particular asynchronous task?)
>
> > 2. The ProgrammaticLogin doesn't work either with:
> >     listFeed    = client.GetListFeed(spreadKey, workKey)
>
> > On Oct 21, 4:43 pm, Michelschr <michels...@gmail.com> wrote:
> > > Thanks for your answer...
>
> > > Yes I still have a hard time setting the scope!
>
> > > As I explained in the other thread, I had success with:
> > > scope = 'http://spreadsheets.google.com/feeds/list/'+key + '/' +

Tim Garthwaite

unread,
Oct 21, 2009, 11:21:08 AM10/21/09
to gdata-python-client-...@googlegroups.com

Heh, a bit of errata, I obviously meant to say "in favor of OAuth" not "in favor of AuthSub," for the future readers... :-D

Tim Garthwaite
+1 401-405-1513
Appirio: Accelerating Enterprise Adoption of the Cloud
www.appirio.com


Reply all
Reply to author
Forward
0 new messages