NotAllowedError using users.create_login_url

51 ogledov
Preskoči na prvo neprebrano sporočilo

Stuart Cameron

neprebran,
22. okt. 2016, 20:10:5322. 10. 16
do Google App Engine
I am having trouble with a very basic example using `users.create_login_url` based on the example code in the [How-to guide](https://cloud.google.com/appengine/docs/python/users/). The example works fine in the local development server but not when deployed to appspot.com.

import webapp2
import urllib2
from google.appengine.api import users
 
class Main(webapp2.RequestHandler):
   
def get(self):
        login_url
= users.create_login_url('/')
       
self.response.write(login_url)
   
app
= webapp2.WSGIApplication([
       
('/', 'Main'),
], debug=True)


Questions such as [this one on StackOverflow](http://stackoverflow.com/questions/19676367/notallowederror-on-front-main-page) suggest the problem is using Google Apps domain instead of Google Accounts API, which I think refers to the setting pictured below. Altering these settings has not fixed the problem.

What is likely to be causing this?

  

Adam (Cloud Platform Support)

neprebran,
23. okt. 2016, 12:36:3123. 10. 16
do Google App Engine
The first error I'd expect you to get would be "import_string() failed for 'Main'", because the tuple passed to webapp2.WSGIApplication() should include a class, not a string. Changing ('/', 'Main') to ('/', Main) otherwise causes the above code to work fine for me. I'm just using the following simple app.yaml:

runtime: python27
api_version
: 1
threadsafe
: true

handlers
:
- url: /.*
  script
: main.app

Have you tried deploying to a new project?
Odgovori vsem
Odgovori avtorju
Posreduj
0 novih sporočil