Issues with SSO and '~' character

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 encoded bytes. 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.

5 Likes