Hi all,
I've noticed that a few people are trying to use ClientLogin with one
master account on App Engine, so allow me to explain with a big caveat
up front: this technique can cause auth tokens to be shared by
everyone who uses your App Engine app.
Unless you are using one master account that you want all of your
users to share, please do not use this technique.
First, you'll need to tell your Google Data service client that it is
running on App Engine:
client = gdata.service.GDataService() # or some subclass of
GDataService, like DocsService
gdata.alt.appengine.run_on_appengine(client)
By default, the above modifies the token_store so that all auth tokens
must be associated with a user. When your app has a current_user, the
token is stored in the datastore, if there is no current user, the
token is discarded. I required that tokens be associated with a user
since some parts of your app can stay in memory across requests to
your app and it is possible that you might write your app in a way
that could cause tokens to be used for the wrong user. I've tried to
make it more difficult for you to make such a mistake. If you are
using one shared account, then it is ok for all of your app users to
have access to the same auth token. We can replace the token store
with one that keeps all tokens in memory and does not associate them
with any user:
client.token_store = atom.token_store.TokenStore()
Then use ClientLogin(), or ProgrammaticLogin(), etc.
Let me repeat one more time, after you make this change, and depending
on how your client is initialized, it is possible for auth tokens from
one user to stay in memory and be reused in other requests, so make
sure that you really want all users to see data for this account. I
can't emphasize enough that this modification should only be used in
very limited circumstances.
Thank you,
Jeff
On Sep 17, 12:47 pm, Jeff S <[EMAIL PROTECTED]> wrote:
> Hi AAG,
>
> I can see why this is failing, and it is actually by design. The new
> version of the library stores the auth tokens in the App Engine
> datastore - but - it only stores them if there is a current user.
> Since I imagine you are probably not signed in to your app when you
> visit this page, the SetCredentials will not work. The simple solution
> would be to sign in to your app before viewing this page.
>
> There is a way to perform the authorization without signing in, but it
> would be a bit more complicated in this context, and I'd rather not
> explain it unless signing in will not suit your needs.
>
> Thank you,
>
> Jeff
>
> On Sep 15, 12:08 pm, AAG <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi Jeff,
>
> > I installed the gdata.py-1.2.1 and in the AppEngine server the same
> > fault appears. And now in the local server appears the following
> > fault :
>
> > H:\GAE\Eclipse\AAG\workspace\helloworld\src\gdata\service.py in
> > PostOrPut(self=<gdata.docs.service.DocsService object at 0x019B9330>,
> > verb='POST', data=<gdata.GDataEntry object at 0x02305EF0>, uri='/feeds/
> > documents/private/full', extra_headers={'Content-Length': '396',
> > 'Content-Type': 'multipart/related; boundary=END_OF_PART', 'MIME-
> > version': '1.0', 'Slug': None}, url_params=None, escape_params=True,
> > redirects_remaining=4, media_source=<gdata.MediaSource object at
> > 0x022DDAB0>, converter=None)
> > 949 else:
>
> > 950 raise RequestError, {'status': server_response.status,
>
> > 951 'reason': server_response.reason, 'body': result_body}
>
> > 952
>
> > 953 def Put(self, data, uri, extra_headers=None, url_params=None,
> > server_response = <gdata.alt.appengine.HttpResponse object at
> > 0x02305EB0>, server_response.reason = '', result_body = '<HTML>\n<HEAD>
> > \n<TITLE>Authorization required</TIT...required</H1>\n<H2>Error 401</
> > H2>\n</BODY>\n</HTML>\n'
>
> > <class 'gdata.service.RequestError'>: {'status': 401, 'body': '<HTML>
> > \n<HEAD>\n<TITLE>Authorization required</TITLE>\n</HEAD>\n<BODY
> > BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Authorization required</H1>
> > \n<H2>Error 401</H2>\n</BODY>\n</HTML>\n', 'reason': ''}
> > args = ({'body': '<HTML>\n<HEAD>\n<TITLE>Authorization required</
> > TIT...required</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n',
> > 'reason': '', 'status': 401},)
> > message = {'body': '<HTML>\n<HEAD>\n<TITLE>Authorization
> > required</TIT...required</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>
> > \n', 'reason': '', 'status': 401}
>
> > My code is:
>
> > import atom
> > import atom.service
>
> > import gdata.spreadsheet.text_db
> > import gdata.spreadsheet.service
>
> > import gdata.docs
> > import gdata.docs.service
>
> > import gdata.service
> > import gdata.alt.appengine
> > import gdata.alt
>
> > import gdata.urlfetch
> > # Use urlfetch instead of httplib
> > gdata.service.http_request_handler = gdata.urlfetch
>
> > username = '[EMAIL PROTECTED]'
> > password = 'password'
>
> > client = gdata.spreadsheet.text_db.DatabaseClient()
> > gdata.alt.appengine.run_on_appengine(client._GetDocsClient())
> > gdata.alt.appengine.run_on_appengine(client._GetSpreadsheetsClient())
>
> > client.SetCredentials(username, password)
>
> > db = client.CreateDatabase('TestAAG12')
>
> > table = db.CreateTable('Invoice', ['a', 'b', 'c'])
> > row1 = table.AddRecord({'a':'21', 'b':'2008', 'c':'1'})
> > row2 = table.AddRecord({'a':'21', 'b':'2008', 'c':'2'})
>
> > How can i solve this issue ?
>
> > Thanks in advance,
> > AAG
> > Pinxer.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Docs Data APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Docs-Data-APIs?hl=en
-~----------~----~----~----~------~----~------~--~---