import base64


def base64_encode(s):
    """Encode a URL-safe string.

    :type s: six.text_type
    :rtype: six.text_type

    """
    # urlsafe_b64encode() returns six.binary_type so need to convert to
    # six.text_type, might as well do it before stripping.
    return base64.urlsafe_b64encode(s).decode('utf-8').rstrip('=')