Odd problem with Incorrect padding error in Oauth2 flow using Django >=2.0

23 views
Skip to first unread message

Malcolm MacKinnon

unread,
Jun 10, 2018, 10:12:52 PM6/10/18
to Django users

Using python 3.55 and django 1.10 in my Oauth2 flow (with django_openid_auth in my installed apps),
my code executes without any errors. But in a python 3.55 and django >=2.0 environment, I get the following error:

Error at /openid/login/

Incorrect padding

I've spent two days searching for what's causing this and haven't found anything. There is some discussion here:
and here:

But, I haven't found a solution. Does anyone know the reason why this is happening or have a solution?


Here's my traceback:
Internal Server Error: /openid/login/
Traceback (most recent call last):
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/malcolm/qb6/qb5/django_openid_auth/views.py", line 191, in login_begin
    openid_request = consumer.begin(openid_url)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 359, in begin
    return self.beginWithoutDiscovery(service, anonymous)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 382, in beginWithoutDiscovery
    auth_req = self.consumer.begin(service)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 610, in begin
    assoc = self._getAssociation(service_endpoint)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 1178, in _getAssociation
    assoc = self.store.getAssociation(endpoint.server_url)
  File "/home/malcolm/qb6/qb5/django_openid_auth/store.py", line 80, in getAssociation
    base64.decodestring(assoc.secret.encode('utf-8')),
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/base64.py", line 562, in decodestring
    return decodebytes(s)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/base64.py", line 554, in decodebytes
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
ERROR:django.request:Internal Server Error: /openid/login/
Traceback (most recent call last):
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/malcolm/qb6/qb5/django_openid_auth/views.py", line 191, in login_begin
    openid_request = consumer.begin(openid_url)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 359, in begin
    return self.beginWithoutDiscovery(service, anonymous)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 382, in beginWithoutDiscovery
    auth_req = self.consumer.begin(service)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 610, in begin
    assoc = self._getAssociation(service_endpoint)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/site-packages/openid/consumer/consumer.py", line 1178, in _getAssociation
    assoc = self.store.getAssociation(endpoint.server_url)
  File "/home/malcolm/qb6/qb5/django_openid_auth/store.py", line 80, in getAssociation
    base64.decodestring(assoc.secret.encode('utf-8')),
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/base64.py", line 562, in decodestring
    return decodebytes(s)
  File "/home/malcolm/anaconda3/envs/qb6/lib/python3.5/base64.py", line 554, in decodebytes
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
[11/Jun/2018 01:44:19] "GET /openid/login/?next=/quick/authCodeHandler%3Fstate%3Da2tbp1iauv66p9o8pnndhjfmy6fc8njotrgkppbx%26code%3DL011528681818rdMG5DmLYzdLfwvyaRcHY02PaWYoxkoxEP2w4%26realmId%3D123145812832527 HTTP/1.1" 500 150348


Reply all
Reply to author
Forward
0 new messages