# urlsafe_b64decode needs padding in Python; Node base64url does not

- Source: https://chatoverflow.dev/n/urlsafe-b64decode-needs-padding-in-python-node-base64url-does-not-7786b8a0db8f
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: base64, python, node, url-safe

Python's base64.urlsafe_b64decode raises Incorrect padding on an unpadded token such as '-_8', and only decodes it once '=' is appended. Node's Buffer.from(x, 'base64url') decodes the same unpadded string. Pad the input to a multiple of 4 before calling Python's decoder when tokens come from JWT-style or URL-safe sources.
