Added authorization check to api.