public override Task Authenticated(MicrosoftAccountAuthenticatedContext context)
        {
            string avatarUrl = string.Format("https://apis.live.net/v5.0/{0}/picture",
                                             context.User.GetValue("id").ToString());

            context.Identity.AddClaim(
                new Claim(OwinHelper.ClaimTypeAvatarUrl, avatarUrl));

            return(base.Authenticated(context));
        }
Ejemplo n.º 2
0
 public override Task Authenticated(MicrosoftAccountAuthenticatedContext context)
 {
     // In some cases (hotmail.com and others) the email is empty, but the email is in the userPrincipalName.
     // Override with this. See https://github.com/aspnet/AspNetKatana/issues/107
     if (string.IsNullOrEmpty(context.Email) && context.User.GetValue("userPrincipalName") != null)
     {
         context.Identity.AddClaim(new Claim("email", context.User.GetValue("userPrincipalName").ToString()));
     }
     return(base.Authenticated(context));
 }
Ejemplo n.º 3
0
        public override Task Authenticated(MicrosoftAccountAuthenticatedContext context)
        {
            context.Identity.AddClaims(
                new List <Claim>
            {
                new Claim(AccessToken, context.AccessToken),
                new Claim(UserId, context.Id),
                new Claim(Email, context.Email ?? ""),
                new Claim(FirstName, context.FirstName),
                new Claim(LastName, context.LastName)
            });

            return(base.Authenticated(context));
        }
        internal static async Task OnAuthenticated(MicrosoftAccountAuthenticatedContext context)
        {
            if (context.Identity != null)
            {
                Helpers.ThrowIfConditionFailed(() => context.AccessToken == "ValidAccessToken", "Access token is not valid");
                Helpers.ThrowIfConditionFailed(() => context.RefreshToken == "ValidRefreshToken", "Refresh token is not valid");
                Helpers.ThrowIfConditionFailed(() => context.FirstName == "AspnetvnextTest", "Email is not valid");
                Helpers.ThrowIfConditionFailed(() => context.LastName == "AspnetvnextTest", "Email is not valid");
                Helpers.ThrowIfConditionFailed(() => context.Id == "fccf9a24999f4f4f", "Id is not valid");
                Helpers.ThrowIfConditionFailed(() => context.Name == "AspnetvnextTest AspnetvnextTest", "Name is not valid");
                Helpers.ThrowIfConditionFailed(() => context.ExpiresIn.Value == TimeSpan.FromSeconds(3600), "ExpiresIn is not valid");
                Helpers.ThrowIfConditionFailed(() => context.User != null, "User object is not valid");
                Helpers.ThrowIfConditionFailed(() => context.Id == context.User.SelectToken("id").ToString(), "User id is not valid");
                context.Identity.AddClaim(new Claim("ManageStore", "false"));
            }

            await Task.FromResult(0);
        }
Ejemplo n.º 5
0
 public override Task Authenticated(MicrosoftAccountAuthenticatedContext context)
 {
     try
     {
         addClaim(context.Identity, "urn:tokens:microsoft:accesstoken", context.AccessToken);
         //
         addClaim(context.Identity, "urn:tokens:microsoft:familyname", getValue(context.User, "last_name"));
         addClaim(context.Identity, "urn:tokens:microsoft:givenname", getValue(context.User, "first_name"));
         addClaim(context.Identity, "urn:tokens:microsoft:avatarurl", $@"https://apis.live.net/v5.0/{context.Id}/picture"); //?width=240&height=240
         addClaim(context.Identity, "urn:tokens:microsoft:company", getValue(context.User, "company"));
         //
         //addClaim(context.Identity, "providerKey", context.Identity.AuthenticationType);
         //addClaim(context.Identity, System.Security.Claims.ClaimTypes.Name, context.Identity.FindFirstValue(System.Security.Claims.ClaimTypes.Name));
     }
     catch (Exception ex) { Logger.Error(ex, LogCategory.Claims, "There was an issue reading the information from the Facebook Authentication context."); }
     //
     return(base.Authenticated(context));
 }