python: OIDC + Python3 + Incorrect padding during base64decode

Using 3.6.5

  File "/usr/lib/python3.6/site-packages/kubernetes-6.0.0_snapshot-py3.6.egg/kubernetes/config/kube_config.py", line 474, in load_kube_config
  File "/usr/lib/python3.6/site-packages/kubernetes-6.0.0_snapshot-py3.6.egg/kubernetes/config/kube_config.py", line 355, in load_and_set
  File "/usr/lib/python3.6/site-packages/kubernetes-6.0.0_snapshot-py3.6.egg/kubernetes/config/kube_config.py", line 185, in _load_authentication
  File "/usr/lib/python3.6/site-packages/kubernetes-6.0.0_snapshot-py3.6.egg/kubernetes/config/kube_config.py", line 237, in _load_oid_token
  File "/usr/lib/python3.6/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

When attempting to decode the token, I run into this issue in _load_oid_token

  if PY3:
    jwt_attributes = json.loads(
      base64.b64decode(parts[1]).decode('utf-8')
    )

The non py3 block appends “==” to the token part before decoding it. If i use that, it works fine.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Can I bump this? My existing code is Python 3.6 and I can’t port it back to 2.x due to other libraries. The PR works for me, can we get it pushed into PyPi plz? Thank you.