def strip_bearer(token):
    """Strip the bearer text from the token if present

    :returns: The token string without the bearer keyword.

    E.g.::

        'bearer 1234' -> '1234'
        '1234' -> '1234'

    """
    # remove trailing spaces
    _token = token.strip()

    # split on gap between bearer and token (if any)
    parts = token.split(' ')

    # if the gap has more than on space strip all spaces
    parts = [part for part in parts if part]

    # return everything at the end of the list and make it into a string.
    _token = "".join(parts[-1:])

    return _token