refactor auth to use sendRequestToEndpoint