def effective_authority(request):
    """
    Return the authority associated with an request.

    This will try the auth client first, then will return the results of
    `default_authority()`.
    """
    if request.identity and request.identity.auth_client:
        return request.identity.auth_client.authority

    # We could call the method directly here, but instead we'll go through the
    # request method attached below. This allows us to benefit from caching
    # if the method has been called before. Also if the request method ever
    # points to a new function, we don't have to update.
    return request.default_authority