public async Task <UserViewModel> GetUserFromGraphApiAsync() { var accessToken = await _identityService.GetAccessTokenAsync(); if (string.IsNullOrEmpty(accessToken)) { return(null); } var userData = await _microsoftGraphService.GetUserInfoAsync(accessToken); if (userData != null) { userData.Photo = await _microsoftGraphService.GetUserPhoto(accessToken); await ApplicationData.Current.LocalFolder.SaveAsync(_userSettingsKey, userData); } return(await GetUserViewModelFromData(userData)); }
private async Task <UserViewModel> GetUserFromGraphApiAsync() { var accessToken = await _identityService.GetAccessTokenForGraphAsync(); if (string.IsNullOrEmpty(accessToken)) { return(null); } var userData = await _microsoftGraphService.GetUserInfoAsync(accessToken); if (userData != null) { userData.Photo = await _microsoftGraphService.GetUserPhoto(accessToken); var folderPath = Path.Combine(_localAppData, _config.ConfigurationsFolder); var fileName = _config.UserFileName; _fileService.Save <User>(folderPath, fileName, userData); } return(GetUserViewModelFromData(userData)); }
public async Task <UserProfile> Get() { User User = await _graphService.GetUserProfile(); string Photo64Base; try { Photo64Base = await _graphService.GetUserPhoto(); } catch (Exception CaughtException) { Photo64Base = null; } UserProfile Profile = new UserProfile() { User = User, Photo64Base = Photo64Base }; return(Profile); }