Ejemplo n.º 1
0
        protected override void SetIdentityInformations(ClaimsIdentity identity, string claimedID, IDictionary <string, string> attributeExchangeProperties)
        {
            var accountIDMatch = _accountIDRegex.Match(claimedID);

            if (!accountIDMatch.Success)
            {
                return;
            }
            var accountID       = accountIDMatch.Groups[1].Value;
            var getUserInfoTask = HTTPClient.GetStringAsync(string.Format(UserInfoUri, Options.AppId, accountID));

            getUserInfoTask.Wait();
            var     userInfoRaw = getUserInfoTask.Result;
            dynamic userInfo    = JsonConvert.DeserializeObject(userInfoRaw);

            identity.AddClaim(new Claim(ClaimTypes.Name, (string)userInfo["data"][accountID].nickname, "http://www.w3.org/2001/XMLSchema#string", Options.AuthenticationType));
        }