我正在使用Flickr的OAuth的authlib的Flask Client(authlib.flask.client)。在我的机器上,它工作正常,但是在Heroku和Cloud Run(GCP)上运行时,在authorize_redirect方法中遇到错误。我的登录和授权方法均与Flask Client文档中所述完全相同。
@app.route("/login")
def login():
user_id = uuid.uuid4()
user_id = str(user_id)
session["current_user"] = user_id
redirect_uri = url_for('authorize', _external=True)
return oauth.flickr.authorize_redirect(redirect_uri)
@app.route('/authorize')
def authorize():
token = oauth.flickr.authorize_access_token()
repository.add_token(session.get("current_user", ""), token)
redirect_url = "http://localhost:4200/#/login/"
redirect_url = redirect_url + session.get("current_user", "")
return redirect(redirect_url)
错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2311, in wsgi_app response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1834, in full_dispatch_request rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1737, in handle_user_exception reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise raise value
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args)
File "/app/main.py", line 130, in login return oauth.flickr.authorize_redirect(redirect_uri)
File "/usr/local/lib/python3.7/site-packages/authlib/flask/client/oauth.py", line 244, in authorize_redirect **kwargs)
File "/usr/local/lib/python3.7/site-packages/authlib/client/client.py", line 122, in generate_authorize_redirect with self._get_session() as session:
File "/usr/local/lib/python3.7/site-packages/authlib/client/client.py", line 181, in _get_session **self.client_kwargs
TypeError: type object argument after ** must be a mapping, not str