public async Task SignIn(string accountId, string token, CancellationToken cancellationToken) { IHarvestRestClient harvestClient = factory.CreateHarvestRestClient(token, accountId); try { User user = await harvestClient.Users.GetCurrentAsync(); SetPrincipal(user); WriteToFile($"{accountId}#!#{token}"); await NavigateToAsync <TimeEntriesReportViewModel>(cancellationToken); } catch (System.Exception) { MessageBox.Show("Wrong Account Id or Token"); } }
public TimeEntriesReportViewModel( IHarvestRestClientFactory harvestClientFactory, IEnumerable <Rule> rules, IPrincipal principal, ILogger <TimeEntriesReportViewModel> logger) : base(logger) { //harvestClient = new HarvestRestClient(token, accountId); userCache = new Dictionary <int, User>(); Clients = new BindableCollection <ClientModel>(); Projects = new BindableCollection <ProjectModel>(); Projects.CollectionChanged += Projects_CollectionChanged; string bearerToken = ((ClaimsPrincipal)principal).FindFirst("harvest:token").Value; string accountId = ((ClaimsPrincipal)principal).FindFirst("harvest:accountId").Value; harvestClient = harvestClientFactory.CreateHarvestRestClient(bearerToken, accountId); this.rules = rules ?? throw new ArgumentNullException(nameof(rules)); this.principal = principal; PropertyChanged += OnPropertyChange; }