def oauth_token_required(func):
    """
    A decorator to require that
    request.user.oauth_token exists.
    """
    @wraps(func)
    def inner(request, *args, **kwargs):
        """
        Try to get token and redirect to oauth_login
        if not found.
        """
        try:
            _ = request.user.oauth_token
        except (__HOLE__, OAuthToken.DoesNotExist):
            return redirect('oauth_login')

        return func(request, *args, **kwargs)

    return inner
dataset/ETHPy150Open m-vdb/github-buildservice-boilerplate/buildservice/utils/decorators.py/oauth_token_required