def METHOD_NAME(request):
    if "access_token" in request.form:
        return request.form["access_token"]
    if "access_token" in request.args:
        return request.args["access_token"]
    # For a gracefully transition, we will temporarily be accepting both
    # HTTP Auth (which will overwrite the Authorization header) and
    # a Bearer token. During this period, we need to look for a Bearer
    # token in both headers. Once clients switch to Authorization
    # we will remove support for X-Authorization.
    auth = request.headers.get("Authorization", None)
    if not auth:
        raise AuthError({"code": "authorization_header_missing", "description": "Authorization header is expected"}, 401)
    parts = auth.split()
    if parts[0].lower() != "bearer":
        raise AuthError({"code": "invalid_header", "description": "Authorization header must start with Bearer"}, 401)
    elif len(parts) == 1:
        raise AuthError({"code": "invalid_header", "description": "Token not found"}, 401)
    elif len(parts) > 2:
        raise AuthError({"code": "invalid_header", "description": "Authorization header must be Bearer token"}, 401)
    token = parts[1]
    return token