It looks like urlsafe_b64encode
replaces some characters in the base64 encoding. From the docs:
Encode bytes-like object s using the URL- and filesystem-safe alphabet, which substitutes
-
instead of+
and_
instead of/
in the standard Base64 alphabet, and return the encodedbytes
. The result can still contain=
.
That means the result isn’t standard base64, and won’t be compatible with Discourse’s decoding.
I’d recommend using the normal b64encode
function instead. Your HTTP library should take care of the URL escaping if needed.