public override Task Authenticated(GoogleOAuth2AuthenticatedContext context)
        {
            context.Identity.AddClaim(new Claim(Claims.ExternalAccessToken, context.AccessToken));
            context.Identity.AddClaim(new Claim(Claims.ExternalExpiresIn, context.ExpiresIn.ToString()));

            return base.Authenticated(context);
        }
Ejemplo n.º 2
0
        public Task Authenticated(GoogleOAuth2AuthenticatedContext context)
        {
            context.Identity.AddClaim(new Claim("ExternalAccessToken", context.AccessToken));
            //context.Identity.AddClaim(new Claim("picture", context.User.GetValue("picture").ToString()));
            //context.Identity.AddClaim(new Claim("profile", context.User.GetValue("profile").ToString()));

            return Task.FromResult<object>(null);
        }
Ejemplo n.º 3
0
        public Task Authenticated(GoogleOAuth2AuthenticatedContext context)
        {
            context.Identity.AddClaim(new Claim("external_access_token", context.AccessToken));

            var uri = new Uri(context.User["image"].Value<string>("url"));
            context.Identity.AddClaim(new Claim("picture_url", uri.GetLeftPart(UriPartial.Path)));

            return Task.FromResult<object>(null);
        }
        public override Task Authenticated(GoogleOAuth2AuthenticatedContext context)
        {
            string avatarUrl = context.User
                .SelectToken("image.url")
                .ToString()
                .Replace("sz=50", "sz=240");

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

            return base.Authenticated(context);
        }
        internal async static void GetClaimsPrincipalAuthenticatedExternalCookieForGoogle()
        {
            GoogleAuthProvider googleAuthProvider = new GoogleAuthProvider();
            var gctx = new GoogleOAuth2AuthenticatedContext(new OwinContext(), new JObject(), "123456", "", "");
            List<Claim> claims = new List<Claim>();
            claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", "115247531399035464127}", null, "Google"));
            claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname", "Darren", null, "Google"));
            claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname", "Schwarz", null, "Google"));
            claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "Darren Schwarz", null, "Google"));
            claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", "[email protected]", null, "Google"));
            claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/urn:google:profile", "https://plus.google.com/115247531399035464127}", null, "Google"));
            claims.Add(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/ExternalAccessToken", "ya29.5wE5cDqpwP_XAkoTVCYA7oL56869HCS3upwr-TU1QkBz06GJVYz0YQ4v20UAfqb3M8IqBCA", null, "Google"));
            gctx.Identity = new ClaimsIdentity(claims, "ExternalCookie", "name", "role");

            await googleAuthProvider.Authenticated(gctx);

            ClaimsPrincipal principal = new ClaimsPrincipal(gctx.Identity);
            Thread.CurrentPrincipal = principal;
            ClaimsPrincipal.ClaimsPrincipalSelector = () => principal;
        }
Ejemplo n.º 6
0
 public Task Authenticated(GoogleOAuth2AuthenticatedContext context)
 {
     context.Identity.AddClaim(new Claim("ExternalAccessToken", context.AccessToken));
     return Task.FromResult<object>(null);
 }
 //G , F 驗證完畢 , 會透過 ASP.NET 預設的 http://localhost:1520/signin-google 進行導向。
 //而導向完後,就會進入底下方法,並且於 context 紀錄登入過後的資訊 ( 也就是說,取得相關資訊的事情..MS都處理掉了.. )
 public Task Authenticated(GoogleOAuth2AuthenticatedContext context)
 {
     //取得外部登入的存取 Token ,例如,取得存取 Google 帳號資訊的 Token
     context.Identity.AddClaim(new Claim("ExternalAccessToken", context.AccessToken));
     return Task.FromResult<object>(null);
 }
 public Task Authenticated(GoogleOAuth2AuthenticatedContext context)
 {
     context.Identity.AddClaim(new Claim(GenericNames.AUTHENTICATION_EXTERNAL_LOGIN, context.AccessToken));
     return Task.FromResult<object>(null);
 }
 /// <summary>
 /// Invoked whenever Google succesfully authenticates a user
 /// </summary>
 /// <param name="context">Contains information about the login session as well as the user <see cref="System.Security.Claims.ClaimsIdentity"/>.</param>
 /// <returns>A <see cref="Task"/> representing the completed operation.</returns>
 public virtual Task Authenticated(GoogleOAuth2AuthenticatedContext context)
 {
     return OnAuthenticated(context);
 }