def _try_b32_decode(v):
    """
    Attempt to decode a b32-encoded username which is sometimes generated by
    internal Globus components.

    The expectation is that the string is a valid ID, username, or b32-encoded
    name. Therefore, we can do some simple checking on it.

    If it does not appear to be formatted correctly, return None.
    """
    # should start with "u_"
    if not v.startswith("u_"):
        return None
    # usernames have @ , we want to allow `u_foo@example.com`
    # b32 names never have @
    if "@" in v:
        return None
    # trim "u_"
    v = v[2:]
    # wrong length
    if len(v) != 26:
        return None

    # append padding and uppercase so that b32decode will work
    v = v.upper() + (6 * "=")

    # try to decode
    try:
        return str(uuid.UUID(bytes=base64.b32decode(v)))
    # if it fails, I guess it's a username? Not much left to do
    except ValueError:
        return None
Attempt to decode a b32-encoded username which is sometimes generated by
    internal Globus components.

    The expectation is that the string is a valid ID, username, or b32-encoded
    name. Therefore, we can do some simple checking on it.

    If it does not appear to be formatted correctly, return None.