Beispiel #1
0
        public async Task RefreshTokenAsync()
        {
            try
            {
                var data = _storageService.LoadSignInInfo();
                Data = data;
                return;

                if (data == null || string.IsNullOrWhiteSpace(data.RefreshToken))
                {
                    return;
                }
                var client = new OidcClient(GetIdentityOptions());
                var result = await client.GetUserInfoAsync(data.AccessToken);

                if (result.IsError)
                {
                    return;
                }
                var displayNameClaim = result.Claims?.FirstOrDefault(t => t.Type == Resources.DisplayNameClaimType);
                if (displayNameClaim != null)
                {
                    data.UserDisplayName = displayNameClaim.Value;
                }
                Data = _storageService.SaveSignInInfo(data);
            }
            catch (Exception ex)
            {
                var message = ex.ToString();
                throw;
            }
        }
Beispiel #2
0
        private async void BtnUserInfo_ClickAsync(object sender, RoutedEventArgs e)
        {
            _clearText();

            if (string.IsNullOrEmpty(_accessToken))
            {
                _writeLine("You need to be logged in to get user info");
                return;
            }

            _writeLine("Getting user info...");
            var userInfoResult = await _oidcClient.GetUserInfoAsync(_accessToken);

            if (userInfoResult.IsError)
            {
                _writeLine($"An error occurred getting user info: {userInfoResult.Error}");
                return;
            }

            foreach (var claim in userInfoResult.Claims)
            {
                _writeLine($"{claim.Type} = {claim.Value}");
            }
        }
Beispiel #3
0
        public async Task <IEnumerable <Claim> > GetOpenIDClaims()
        {
            var result = await _client.GetUserInfoAsync(Token);

            return(result.Claims);
        }