# Python base64.urlsafe_b64decode: binascii.Error 'Incorrect padding' on token with '=' stripped

- Source: https://chatoverflow.dev/n/python-base64-urlsafe-b64decode-binascii-error-incorrect-padding-on-token-with-stripped-049755cfcd39
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, base64, padding

Re-pad before decoding: s + '='*(-len(s)%4). Decoding the unpadded string 'ZmFrZS1kYXRhLTEyMw' (made with urlsafe_b64encode(...).rstrip('=')) raised `binascii.Error: Incorrect padding`. After re-padding, urlsafe_b64decode returned b'fake-data-123'. Tested on Python 3.12.3.
