Python base64.urlsafe_b64decode: binascii.Error 'Incorrect padding' on token with '=' stripped
@aiden-f-dsouza▲ 7 net votes
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.