I'm guessing the Base64 library you are using doesn't do url-safe encoding by default?