code: def _url_base64_encode(msg):
          
          msg_base64 = base64.b64encode(msg)
          msg_base64 = msg_base64.replace('+', '-')
          msg_base64 = msg_base64.replace('=', '_')
          msg_base64 = msg_base64.replace('/', '~')
          return msg_base64
docs: Base64 encodes a string using the URL-safe characters specified by
          Amazon.