Function 首页主页上不允许出现错误'/';

Function 首页主页上不允许出现错误'/';,function,google-app-engine,exception-handling,Function,Google App Engine,Exception Handling,我试图将用户的主页'/'设置为登录或不登录,但我得到了一个不允许的错误。这在本地服务器中起作用。但是,它在真正的公共服务器中似乎不起作用 NotAllowedError是否意味着遵守谷歌应用程序引擎标准,即不在首页登录,或者可能是其他什么 以下是错误: Traceback (most recent call last): File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.

我试图将用户的主页
'/'
设置为登录或不登录,但我得到了一个
不允许的错误
。这在本地服务器中起作用。但是,它在真正的公共服务器中似乎不起作用

NotAllowedError
是否意味着遵守谷歌应用程序引擎标准,即不在首页登录,或者可能是其他什么

以下是错误:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~map-jobs/2.371277816538602179/main.py", line 294, in get
    user_url = users.create_login_url() # raise NotAllowedError
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/users.py", line 256, in create_login_url
    raise NotAllowedError
NotAllowedError
这是我的
MainHandler

class MainHandler(BaseHandler):
  def get(self):
    user = users.get_current_user()
    logout_url = users.create_logout_url(self.request.uri)
    profile=''
    if user:
      profile = Profile.query(Profile.user_id==user.user_id())
      if profile.count() <= 0:
        profile = Profile()
        profile.user_id = user.user_id()
        profile.email = user.email()
        profile.firstname = user.nickname()
        profile_key = profile.put()
      else:
        profile_key = Profile.query(Profile.user_id==user.user_id())
      profile = profile_key.get()
      current_user = 'Hello, '+ user.nickname()
      user_url = logout_url
      title = "Click to logout from Google."
    else:
      current_user = 'Google Sign in'
      user_url = users.create_login_url(self.request.uri) # raise NotAllowedError
      title = "Click to sign in with your Google Account."
    values = {
      'current_user' : current_user,
      'user_url' : user_url,
      'profile' : profile,
    }
    self.render_html('index.html',values)
这是我的app.yaml:

application: map-jobs
version: 2
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /(.*\.(gif|png|jpg|js|css|woff|ttf|svg))
  static_files: static/\1
  upload: static/(.*\.(gif|png|jpg|js|css|woff|ttf|svg))

- url: /templates/.*
  script: templates.app

- url: .*
  script: main.app


libraries:
- name: webapp2
  version: "2.5.2"

- name: jinja2
  version: "2.6"

没关系,我只是犯了个错误。在我的应用程序设置中,我应该使用谷歌帐户API而不是谷歌应用程序域

您尚未显示您的app.yaml以及您启用的身份验证类型(例如谷歌应用程序、openid等)。我猜在有限的信息中,发生了如下情况,你有应用程序域登录的身份验证,但用户已经登录到谷歌,但不是谷歌应用程序域,因此无法创建登录url。你应该详细说明你的设置。我已经添加了我的app.yaml.yep,我想它会是这样的。这个对话中的设置是关于应用程序登录(GAE登录)和OAuth登录,可以在Google API控制台中使用API密钥找到。很难复制和解释,但这涉及到使用两种身份验证。只能使用一个登录名。一旦您确定要使用哪一个,用户就可以使用来自API的信息。
application: map-jobs
version: 2
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /(.*\.(gif|png|jpg|js|css|woff|ttf|svg))
  static_files: static/\1
  upload: static/(.*\.(gif|png|jpg|js|css|woff|ttf|svg))

- url: /templates/.*
  script: templates.app

- url: .*
  script: main.app


libraries:
- name: webapp2
  version: "2.5.2"

- name: jinja2
  version: "2.6"