Thanks Johan
Even though I have signed in using my Gmail account it does not seem
to make any difference. It is displaying the same error.

And also i tried using the oauthdecorator
1. when I click on yes or no button for a particular submission it
requests for login and after I sign in it displays this error:
OAuth 2.0 error: redirect_uri_mismatch
The redirect URI in the request did not match a registered redirect
URI

Can you please tell why this error appears and how to solve this
On Jun 18, 4:17 am, Johan Euphrosine <[email protected]> wrote:
> get_current_user() could return None has documented here, if no user
> is logged in:http://code.google.com/appengine/docs/python/users/functions.html
>
> You could also take a look at the new OAuth2Decorator in
> google-api-python-client that make dealing with OAuth 2.0 
> easier:http://code.google.com/p/google-api-python-client/wiki/OAuth2AppEngin...
>
> I just published an article on how to use it with Google Tasks API,
> but that should be easy to translate to Moderator 
> API:http://googleappengine.blogspot.com/2011/06/getting-started-with-task...
>
> On Fri, Jun 17, 2011 at 2:45 PM, GAE app developer
>
>
>
>
>
>
>
>
>
> <[email protected]> wrote:
> > Hi,
>
> > I am developing an Google app engine application using Moderator API
> > in python. I am able to retrieve the submissions. I am having an
> > authentication problem. My code runs locally without any problem but
> > when I deploy it in Google app engine launcher. It shows the following
> > error:
>
> > 'NoneType' object has no attribute 'user_id'
> > Traceback (most recent call last):
> >  File "/base/python_runtime/python_lib/versions/1/google/appengine/
> > ext/webapp/__init__.py", line 700, in __call__
> >    handler.get(*groups)
> >  File "/base/data/home/apps/ktbookstore/3.351197542995528852/
> > retrieve_list_unique.py", line 107, in get
> >    f = Flow.get_by_key_name(user.user_id())
> > AttributeError: 'NoneType' object has no attribute 'user_id'
>
> > My code is:
>
> > import gflags
> > import httplib2
> > import logging
> > import pprint
> > import sys
> > import os
> > import cgi
> > import pickle
>
> > from apiclient.discovery import build
> > from oauth2client.file import Storage
> > from oauth2client.client import AccessTokenRefreshError
> > from oauth2client.client import OAuth2WebServerFlow
> > from oauth2client.tools import run
> > from google.appengine.ext import webapp
> > from google.appengine.ext.webapp import template
> > from google.appengine.ext.webapp.util import run_wsgi_app
> > from google.appengine.ext import db
> > from google.appengine.api import users
> > from oauth2client.appengine import CredentialsProperty
> > from oauth2client.appengine import StorageByKeyName
> > from google.appengine.ext.webapp.util import login_required
> > from google.appengine.api import memcache
> > from oauth2client.appengine import FlowProperty
>
> > FLAGS = gflags.FLAGS
>
> > FLOW = OAuth2WebServerFlow(
> >    client_id='My client id',
> >    client_secret='my client_secret',
> >    scope='https://www.example.com/oauth2callback',
> >    user_agent='moderator-cmdline-sample/1.0')
>
> > gflags.DEFINE_enum('logging_level', 'ERROR',['DEBUG', 'INFO',
> > 'WARNING', 'ERROR', 'CRITICAL'],'Set the level of logging detail.')
>
> > class Flow(db.Model):   # FlowThreeLegged could also be stored in
> > memcache.
> >    flow = FlowProperty()
>
> > class Credentials(db.Model):
> >  credentials = CredentialsProperty()
>
> > class ModPage(webapp.RequestHandler):
> >  def get(self):
> >    # Let the gflags module process the command-line arguments
>
> >    service = build("moderator", "v1", developerKey='my developer
> > key')
>
> > class voteUpdate(webapp.RequestHandler):
> >  def get(self):
> >      user = users.get_current_user()
> >      logging.info(user)
> >      f = Flow.get_by_key_name(user.user_id())
> >      if f:
> >        credentials = f.flow.step2_exchange(self.request.params)
> >        c = Credentials(key_name=user.user_id(),
> > credentials=credentials)
> >        c.put()
> >        f.delete()
> >        self.redirect("/")
> >      else:
> >        pass
> >      user = users.get_current_user()
> >      c = Credentials.get_by_key_name(user.user_id())
> >      if c:
> >        http = httplib2.Http()
> >        http = c.credentials.authorize(http)
> >      else:
> >        flow = FlowThreeLegged(
> >                              consumer_key='',
> >                              consumer_secret='anonymous',
> >                              user_agent='google-api-client-python-
> > moderator-webapp/1.0',
> >                              domain='anonymous',
> >                              scope='https://www.googleapis.com/auth/
> > moderator',
> >                              xoauth_displayname='Example Web App')
> >      authorize_url = flow.step1_get_authorize_url(STEP2_URI)
> >      f = Flow(key_name=user.user_id(), flow=flow)
> >      f.put()
> >      self.redirect(authorize_url)
>
> >      service = build("moderator", "v1", http=http,developerKey='my
> > developer key')
>
> >      minus=self.request.get("Minus")
> >      if minus=="":
> >        self.response.out.write("plus")
> >        #code which will increment plus vote counter by 1
> >      else:
> >        self.response.out.write("minus")
> >        #code which will increment minus vote counter by 1
>
> > application = webapp.WSGIApplication([
> >  ('/', ModPage),('/vote',voteUpdate)
> > ], debug=True)
>
> > def main():
> >   run_wsgi_app(application)
>
> > if __name__ == '__main__':
> >  main()
>
> > Please help me in finding the solution.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Google App Engine" 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 
> > athttp://groups.google.com/group/google-appengine?hl=en.
>
> --
> Johan Euphrosine (proppy)
> Developer Programs Engineer
> Google Developer Relations

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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-appengine?hl=en.

Reply via email to