正如标题所示,当我的烧瓶应用程序试图运行时,我看到了这个错误。
我使用dev_appserver在本地托管应用程序。
当我访问该网站并尝试运行该应用时,会发生错误。似乎GAE正在尝试并且由于某种原因未能绑定套接字。
我怀疑这可能与OAuth2有关。也许它需要SSL连接?
我甚至不知道从哪里开始解决这个问题,因为关于此事的其他帖子都没有遇到同样的问题变异。
编辑:以下是控制台的屏幕截图,确认GAE服务器在其他端口上成功启动;仍然没有解决它
Traceback (most recent call last):
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "C:\Users\XXX\PycharmProjects\ad-assignment\main.py", line 51, in <module>
app.run()
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\flask\app.py", line 843, in run
run_simple(host, port, self, **options)
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 694, in run_simple
inner()
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 656, in inner
fd=fd)
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 550, in make_server
passthrough_errors, ssl_context, fd=fd)
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 464, in __init__
HTTPServer.__init__(self, (host, int(port)), handler)
File "C:\Python27\Lib\SocketServer.py", line 417, in __init__
self.server_bind()
File "C:\Python27\Lib\BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "C:\Python27\Lib\SocketServer.py", line 431, in server_bind
self.socket.bind(self.server_address)
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\dist27\socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\api\remote_socket\_remote_socket.py", line 676, in bind
raise _SystemExceptionFromAppError(e)
error: [Errno 13] Permission denied
INFO 2016-12-16 21:41:51,631 module.py:788] default: "GET /oauth2callback?code=x/xxxxxxxxxxxxxxxxx HTTP/1.1" 500 -
代码(如Google的OAuth2 usage guide中所示):
import flask
app = flask.Flask(__name__)
@app.route('/')
def index():
...
@app.route('/oauth2callback')
def oauth2callback():
...
if __name__ == 'main':
import uuid
app.secret_key = str(uuid.uuid4())
app.debug = False
app.run()
答案 0 :(得分:1)
我们有tutorial that walks you through adding Firebase Authentication to your Python app running with Flask。 Firebase身份验证是首选的身份工具包。您当然仍然可以使用纯OAuth2流程,但Firebase Auth还提供多提供商身份验证,如果您考虑添加到应用程序中的话。如果您只想深入了解示例代码here on GitHub。
如果您只想坚持使用直接OAuth,您可能需要查看Flask代码本身。 Getting flask to run is pretty easy on App Engine。我的猜测是,您正在调用一些您不需要的代码(flask.run()
),或者您不是importing your library properly(请参阅appengine_config.py
)。< / p>