Exemple #1
0
        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);

                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));
        }