-> url, state = self.session.authorization_url(
(Pdb++) locals()
{'pdb': <module 'pdb' from '/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/_pdbpp_path_hack/pdb.py'>, 'kwargs': {}, 'save_request_token': None, 'callback_uri': 'http://citadel.test.ricebook.net/user/authorized', 'self': <authlib.flask.client.oauth.RemoteApp object at 0x110656898>}
(Pdb++) c
[24] > /Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/authlib/specs/rfc6749/parameters.py(67)prepare_grant_uri()
-> return add_params_to_uri(uri, params)
(Pdb++) locals()
{'pdb': <module 'pdb' from '/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/_pdbpp_path_hack/pdb.py'>, 'params': [('response_type', 'code'), ('client_id', None), ('redirect_uri', 'http://citadel.test.ricebook.net/user/authorized'), ('state', 'xxxxxxxx')], 'kwargs': {}, 'state': 'xxxxxxxx', 'scope': None, 'redirect_uri': 'http://citadel.test.ricebook.net/user/authorized', 'response_type': 'code', 'client_id': None, 'uri': None}
(Pdb++) c
[25] > /Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/authlib/common/urls.py(118)add_params_to_uri()
-> return urlparse.urlunparse((sch, net, path, par, query, fra))
(Pdb++) locals()
{'pdb': <module 'pdb' from '/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/_pdbpp_path_hack/pdb.py'>, 'fra': b'', 'query': 'response_type=code&client_id=None&redirect_uri=http%3A%2F%2Fcitadel.test.ricebook.net%2Fuser%2Fauthorized&state=xxxxxxxx', 'par': b'', 'path': b'', 'net': b'', 'sch': b'', 'fragment': False, 'params': [('response_type', 'code'), ('client_id', None), ('redirect_uri', 'http://citadel.test.ricebook.net/user/authorized'), ('state', 'xxxxxxxx')], 'uri': None}
(Pdb++) c
[2018-01-29 01:05:58 +0800] [72803] [INFO] [_internal.py @ 87]: 127.0.0.1 - - [29/Jan/2018 01:05:58] "GET /user/login HTTP/1.1" 500 -
[2018-01-29 01:05:58 +0800] [72803] [ERROR] [_internal.py @ 87]: Error on request:
Traceback (most recent call last):
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/werkzeug/serving.py", line 267, in run_wsgi
execute(self.server.app)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/werkzeug/serving.py", line 255, in execute
application_iter = app(environ, start_response)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask_sockets.py", line 48, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/timfeirg/eru/citadel/citadel/views/user.py", line 30, in login
url_for('user.authorized', _external=True)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/authlib/client/client.py", line 100, in generate_authorize_redirect
self.authorize_url, **kwargs)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/authlib/client/oauth2.py", line 111, in authorization_url
state=state, **kwargs
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/authlib/specs/rfc6749/parameters.py", line 67, in prepare_grant_uri
return add_params_to_uri(uri, params)
File "/Users/timfeirg/.virtualenvs/citadel/lib/python3.6/site-packages/authlib/common/urls.py", line 118, in add_params_to_uri
return urlparse.urlunparse((sch, net, path, par, query, fra))
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/parse.py", line 454, in urlunparse
_coerce_args(*components))
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/parse.py", line 120, in _coerce_args
raise TypeError("Cannot mix str and non-str arguments")
TypeError: Cannot mix str and non-str arguments
So if the user didn't realize there's a typo in the config, he would have to do some intensive debugging to realize what's actually wrong, so I think it's best to do some config validation, or some encoding conversion during authlib.common.urls.add_params_to_uri
, or anything else to correctly expose the problem.