当前位置: 首页>>代码示例>>C#>>正文


C# Facebook.FacebookAuthenticationOptions类代码示例

本文整理汇总了C#中Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions的典型用法代码示例。如果您正苦于以下问题:C# FacebookAuthenticationOptions类的具体用法?C# FacebookAuthenticationOptions怎么用?C# FacebookAuthenticationOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FacebookAuthenticationOptions类属于Microsoft.Owin.Security.Facebook命名空间,在下文中一共展示了FacebookAuthenticationOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureOAuth

        public void ConfigureOAuth(IAppBuilder app)
        {
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            OAuthBearerOptions = new OAuthBearerAuthenticationOptions();

            OAuthAuthorizationServerOptions oAuthServerOptions = new OAuthAuthorizationServerOptions() {
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(30),
                Provider = new SimpleAuthorizationServerProvider(),
                RefreshTokenProvider = new SimpleRefreshTokenProvider()
            };

            // Token Generation
            app.UseOAuthAuthorizationServer(oAuthServerOptions);
            app.UseOAuthBearerAuthentication(OAuthBearerOptions);

            //Configure Google External Login
            googleAuthOptions = new GoogleOAuth2AuthenticationOptions() {
                ClientId = "xxx",
                ClientSecret = "xxx",
                Provider = new GoogleAuthProvider()
            };
            app.UseGoogleAuthentication(googleAuthOptions);

            //Configure Facebook External Login
            facebookAuthOptions = new FacebookAuthenticationOptions() {
                AppId = "xxx",
                AppSecret = "xxx",
                Provider = new FacebookAuthProvider()
            };
            app.UseFacebookAuthentication(facebookAuthOptions);
        }
开发者ID:kottt,项目名称:OAuthPrototype,代码行数:33,代码来源:Startup.cs

示例2: ConfigureSocialIdentityProviders

        public static void ConfigureSocialIdentityProviders(IAppBuilder app, string signInAsType)
        {
            var google = new GoogleAuthenticationOptions
            {
                AuthenticationType = "Google",
                SignInAsAuthenticationType = signInAsType
            };
            app.UseGoogleAuthentication(google);

            var fb = new FacebookAuthenticationOptions
            {
                AuthenticationType = "Facebook",
                SignInAsAuthenticationType = signInAsType,
                AppId = "676607329068058",
                AppSecret = "9d6ab75f921942e61fb43a9b1fc25c63"
            };
            app.UseFacebookAuthentication(fb);

            var twitter = new TwitterAuthenticationOptions
            {
                AuthenticationType = "Twitter",
                SignInAsAuthenticationType = signInAsType,
                ConsumerKey = "N8r8w7PIepwtZZwtH066kMlmq",
                ConsumerSecret = "df15L2x6kNI50E4PYcHS0ImBQlcGIt6huET8gQN41VFpUCwNjM"
            };
            app.UseTwitterAuthentication(twitter);
        }
开发者ID:vobreshkov,项目名称:Thinktecture.IdentityServer.v3,代码行数:27,代码来源:Startup.cs

示例3: GetFacebookOptions

        private static FacebookAuthenticationOptions GetFacebookOptions()
        {
            var facebookOptions = new FacebookAuthenticationOptions
            {
                AppId = "716319181763981",
                AppSecret = "48e5e982f464d6a9ce610fdca6d2eaa2"
            };
            facebookOptions.Scope.Add("email");
            //facebookOptions.Provider = new FacebookAuthenticationProvider
            //{
            //	OnAuthenticated = async context =>
            //	{
            //		context.Identity.AddClaim(new Claim("AccessToken", context.AccessToken));
            //		context.Identity.AddClaim(new Claim("Id", context.Id));
            //		context.Identity.AddClaim(new Claim("FullName", context.User["name"].ToString()));
            //		context.Identity.AddClaim(new Claim("FirstName", context.User["first_name"].ToString()));
            //		context.Identity.AddClaim(new Claim("LastName", context.User["last_name"].ToString()));
            //		context.Identity.AddClaim(new Claim("Nickname", string.Empty));
            //		context.Identity.AddClaim(new Claim("PhotoLink", string.Format("https://graph.facebook.com/{0}/picture", context.Id)));
            //		context.Identity.AddClaim(new Claim("Email", context.Email));
            //	}
            //};

            return facebookOptions;
        }
开发者ID:Dmitry-Ustimenko,项目名称:lsdteam,代码行数:25,代码来源:Startup.cs

示例4: ConfigureAuth

        // Дополнительные сведения о настройке проверки подлинности см. по адресу: http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Включение использования файла cookie, в котором приложение может хранить информацию для пользователя, выполнившего вход,
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Раскомментируйте приведенные далее строки, чтобы включить вход с помощью сторонних поставщиков входа
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            var x = new FacebookAuthenticationOptions();
            x.Scope.Add("email");
            x.AppId = "698020986995763";
            x.AppSecret = "1e506a050e170e62cb516d065305d81c";
            app.UseFacebookAuthentication(x);

            app.UseGoogleAuthentication(
                clientId: "813562463354-ir13fejg31gfmbb5utv4854m13ft7c6e.apps.googleusercontent.com",
                clientSecret: "dj26JLnwGgXKJS6xB40O0hJU");
        }
开发者ID:wsbaser,项目名称:CoolVocabulary,代码行数:31,代码来源:Startup.Auth.cs

示例5: ChallengeWillTriggerApplyRedirectEvent

 public async Task ChallengeWillTriggerApplyRedirectEvent()
 {
     var options = new FacebookAuthenticationOptions()
     {
         AppId = "Test App Id",
         AppSecret = "Test App Secret",
         Provider = new FacebookAuthenticationProvider
         {
             OnApplyRedirect = context =>
             {
                 context.Response.Redirect(context.RedirectUri + "&custom=test");
             }
         }
     };
     var server = CreateServer(
         app => app.UseFacebookAuthentication(options),
         context =>
         {
             context.Authentication.Challenge("Facebook");
             return true;
         });
     var transaction = await SendAsync(server, "http://example.com/challenge");
     transaction.Response.StatusCode.ShouldBe(HttpStatusCode.Redirect);
     var query = transaction.Response.Headers.Location.Query;
     query.ShouldContain("custom=test");
 }
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:26,代码来源:FacebookMiddlewareTests.cs

示例6: Configure

        public static void Configure(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
              AuthenticationType = DefaultAuthenticationTypes.ExternalCookie
            });

            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure google authentication
            var options = new GoogleOAuth2AuthenticationOptions()
            {
              ClientId = "your app client id",
              ClientSecret = "your app client secret"
            };

            app.UseGoogleAuthentication(options);

            facebookAuthOptions = new FacebookAuthenticationOptions()
            {
            AppId = "528982800546743",
            AppSecret = "a6ee5ad8448c7c67fcedc72d5a4c501a",
            Provider = new FacebookAuthProvider()
            };

            app.UseFacebookAuthentication(facebookAuthOptions);
        }
开发者ID:ozotony,项目名称:UPS,代码行数:29,代码来源:SecurityConfig+.cs

示例7: ConfigureOAuth

        private void ConfigureOAuth(IAppBuilder app)
        {
            app.UseExternalSignInCookie(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ExternalCookie);
            OAuthBearerOptions = new OAuthBearerAuthenticationOptions();

            OAuthAuthorizationServerOptions oAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
                Provider = new SimpleAuthorizationServerProvider(new AccountRepository())
            };

            GoogleAuthOptions = new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "592613624399-a3gr6vveaocnptgvv6738rmnk0pb5cev.apps.googleusercontent.com",
                ClientSecret = "FqNKKib_BP7dsNYBoJa8NwUC",
                Provider = new GoogleAuthProvider()
            };
            app.UseGoogleAuthentication(GoogleAuthOptions);

            FacebookAuthOptions = new FacebookAuthenticationOptions()
            {
                AppId = "806191272841558",
                AppSecret = "1a8241e9d46c4a5e393ae51f265a3489",
                Provider = new FacebookAuthProvider()
            };
            app.UseFacebookAuthentication(FacebookAuthOptions);

            // Token Generation
            app.UseOAuthAuthorizationServer(oAuthServerOptions);
            app.UseOAuthBearerAuthentication(OAuthBearerOptions);
        }
开发者ID:danthomas,项目名称:AngularJSAuthentication,代码行数:33,代码来源:Startup.cs

示例8: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
            {
                AppId = "1610907412530093",
                AppSecret = "c1bf0fa3ed887572a54a21a3ab2f2082"
            };
            facebookAuthenticationOptions.Scope.Add("email");
            app.UseFacebookAuthentication(facebookAuthenticationOptions);

            app.UseGoogleAuthentication(
                clientId: "327546397623-h7gvq4pt4llsasl65pmd0osuddim2r8s.apps.googleusercontent.com",
                clientSecret: "kGGXUiz8aBM1B8X0g-r8iFHT");
        }
开发者ID:anttross,项目名称:events,代码行数:33,代码来源:Startup.Auth.cs

示例9: ConfigureAdditionalIdentityProviders

        public static void ConfigureAdditionalIdentityProviders(IAppBuilder app, string signInAsType)
        {
            var google = new GoogleOAuth2AuthenticationOptions
            {
                AuthenticationType = "Google",
                SignInAsAuthenticationType = signInAsType,
                ClientId = "client", //"767400843187-8boio83mb57ruogr9af9ut09fkg56b27.apps.googleusercontent.com",
                ClientSecret = "secret"  //"5fWcBT0udKY7_b6E3gEiJlze"
            };
            app.UseGoogleAuthentication(google);

            var fb = new FacebookAuthenticationOptions
            {
                AuthenticationType = "Facebook",
                SignInAsAuthenticationType = signInAsType,
                AppId = "app", //"676607329068058",
                AppSecret = "secret"  //"9d6ab75f921942e61fb43a9b1fc25c63"
            };
            app.UseFacebookAuthentication(fb);

            var twitter = new TwitterAuthenticationOptions
            {
                AuthenticationType = "Twitter",
                SignInAsAuthenticationType = signInAsType,
                ConsumerKey = "consumer",  //"N8r8w7PIepwtZZwtH066kMlmq",
                ConsumerSecret = "secret"  //"df15L2x6kNI50E4PYcHS0ImBQlcGIt6huET8gQN41VFpUCwNjM"
            };
            app.UseTwitterAuthentication(twitter);
        }
开发者ID:geffzhang,项目名称:SLEEK-UserAuth,代码行数:29,代码来源:Startup.cs

示例10: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            if (_thirdPartyAuthSettings.LinkedInEnabled
                 && !string.IsNullOrWhiteSpace(_thirdPartyAuthSettings.LinkedInClientId)
                 && !string.IsNullOrWhiteSpace(_thirdPartyAuthSettings.LinkedInClientSecret))
            {
                app.UseLinkedInAuthentication(clientId: _thirdPartyAuthSettings.LinkedInClientId,
                    clientSecret: _thirdPartyAuthSettings.LinkedInClientSecret);
            }

            if (_thirdPartyAuthSettings.FacebookEnabled
                 && !string.IsNullOrWhiteSpace(_thirdPartyAuthSettings.FacebookAppId)
                 && !string.IsNullOrWhiteSpace(_thirdPartyAuthSettings.FacebookAppSecret))
            {
                var facebookAuthenticationOptions = new FacebookAuthenticationOptions
                                                    {
                                                        AppId = _thirdPartyAuthSettings.FacebookAppId,
                                                        AppSecret = _thirdPartyAuthSettings.FacebookAppSecret,
                                                    };
                facebookAuthenticationOptions.Scope.Add("email");
                app.UseFacebookAuthentication(facebookAuthenticationOptions);
            }
            if (_thirdPartyAuthSettings.GoogleEnabled
                    && !string.IsNullOrWhiteSpace(_thirdPartyAuthSettings.GoogleClientSecret)
                    && !string.IsNullOrWhiteSpace(_thirdPartyAuthSettings.GoogleClientId))
            {
                app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
                  {
                      ClientId = _thirdPartyAuthSettings.GoogleClientId,
                      ClientSecret = _thirdPartyAuthSettings.GoogleClientSecret,
                  });
            }
        }
开发者ID:neozhu,项目名称:MrCMS,代码行数:33,代码来源:AuthConfigurationService.cs

示例11: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            var facebookAuthenticationOptions = new FacebookAuthenticationOptions
            {
                AppId = "1480656632147712",
                AppSecret = "971e8d74e63d9a6a5e676bebd5c134ff"
            };
            facebookAuthenticationOptions.Scope.Add("email");
            app.UseFacebookAuthentication(facebookAuthenticationOptions);

            app.UseGoogleAuthentication();
        }
开发者ID:cbenitezatnetmark,项目名称:TechDaysMVC5,代码行数:35,代码来源:Startup.Auth.cs

示例12: ConfigureOAuth

        public void ConfigureOAuth(IAppBuilder app)
        {
            //use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ExternalCookie);
            OAuthBearerOptions = new OAuthBearerAuthenticationOptions();

            OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions() {
            
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(30),
                Provider = new SimpleAuthorizationServerProvider(),
                RefreshTokenProvider = new SimpleRefreshTokenProvider()
            };

            // Token Generation
            app.UseOAuthAuthorizationServer(OAuthServerOptions);
            app.UseOAuthBearerAuthentication(OAuthBearerOptions);

            //Configure Google External Login
            googleAuthOptions = new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "xxxxxx",
                ClientSecret = "xxxxxx",
                Provider = new GoogleAuthProvider()
            };
            app.UseGoogleAuthentication(googleAuthOptions);

            //Configure Facebook External Login
            facebookAuthOptions = new FacebookAuthenticationOptions()
            {
                AppId = System.Configuration.ConfigurationManager.AppSettings["FacebookAppId"],
                AppSecret = System.Configuration.ConfigurationManager.AppSettings["FacebookAppSecret"],
                Provider = new FacebookAuthProvider()
            };
            app.UseFacebookAuthentication(facebookAuthOptions);

            //Configure Twitter External Login
           twitterAuthOptions = new TwitterAuthenticationOptions()
            {
                ConsumerKey = System.Configuration.ConfigurationManager.AppSettings["TwitterConsumerKey"],
                ConsumerSecret = System.Configuration.ConfigurationManager.AppSettings["TwitterConsumerSecret"],
                Provider = new TwitterAuthProvider()
            };
           app.UseTwitterAuthentication(twitterAuthOptions);

           //Configure LinkedIn External Login
           linkedinAuthOptions = new LinkedInAuthenticationOptions()
           {

               ClientId = System.Configuration.ConfigurationManager.AppSettings["LinkedInClientId"],
               ClientSecret = System.Configuration.ConfigurationManager.AppSettings["LinkedInSecret"],
               Provider = new LinkedInAuthProvider()
           };
           app.UseLinkedInAuthentication(linkedinAuthOptions);

           

        }
开发者ID:joropeza,项目名称:AspNetAuth,代码行数:59,代码来源:Startup.cs

示例13: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(IGDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions()
            {
                AppId = ConfigurationManager.AppSettings.Get("FacebookAppId"),
                AppSecret = ConfigurationManager.AppSettings.Get("FacebookAppSecret"),
                Provider = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationProvider()
                {
                    OnAuthenticated = (context) =>
                    {
                        var deserializedUser = JsonConvert.DeserializeObject<FacebookAuthenticatedContextUserModel>(context.User.ToString());

                        context.Identity.AddClaim(new System.Security.Claims.Claim("urn:facebook:access_token", context.AccessToken, XmlSchemaString, "Facebook"));
                        context.Identity.AddClaim(new System.Security.Claims.Claim("urn:facebook:email", context.Email, XmlSchemaString, "Facebook"));
                        context.Identity.AddClaim(new System.Security.Claims.Claim("urn:facebook:first_name", deserializedUser.first_name, XmlSchemaString, "Facebook"));
                        context.Identity.AddClaim(new System.Security.Claims.Claim("urn:facebook:last_name", deserializedUser.last_name, XmlSchemaString, "Facebook"));
                        context.Identity.AddClaim(new System.Security.Claims.Claim("urn:facebook:location", deserializedUser.location.name, XmlSchemaString, "Facebook"));
                        return Task.FromResult(0);
                    }
                }

            };

            facebookOptions.Scope.Add("email");

            app.UseFacebookAuthentication(facebookOptions);
        }
开发者ID:r3wind,项目名称:imgame1,代码行数:59,代码来源:Startup.Auth.cs

示例14: ConfigureAuth

        private void ConfigureAuth(IAppBuilder app)
        {
            app.CreatePerOwinContext(() => new SmartConnectDbContext());
            app.CreatePerOwinContext(
                (IdentityFactoryOptions<SmartConnectUserManager> options, IOwinContext context) =>
                new SmartConnectUserManager(
                    new UserStore<User>(context.Get<SmartConnectDbContext>()),
                    options));
            app.CreatePerOwinContext(
                (IdentityFactoryOptions<SmartConnectSignInManager> options, IOwinContext context) =>
                new SmartConnectSignInManager(
                    context.GetUserManager<SmartConnectUserManager>(),
                    context.Authentication));

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<SmartConnectUserManager, User>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            var facebookOptions = new FacebookAuthenticationOptions()
            {
                AppId = "985705804847366",
                AppSecret = "60f3dd8843d253be4df4c7df53dda6e5",
                BackchannelHttpHandler = new FacebookBackchannelHandler(),
                UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email,first_name,last_name,location"
            };

            facebookOptions.Scope.Add("email");
            app.UseFacebookAuthentication(facebookOptions);

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "223740515644-941v7r26af6sjl5rdsb1oupkcn85mob6.apps.googleusercontent.com",
                ClientSecret = "44TORONTMTTGYpg5j1GcEULS"
            });

            app.MapSignalR();
        }
开发者ID:vassildinev,项目名称:Smart-Connect,代码行数:58,代码来源:Startup.cs

示例15: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Login/SignIn")
            });

            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure social authentication: Twitter
            var naaeTwitterKey = ConfigurationManager.AppSettings["naa4e:twitter:key"];
            var naaeTwitterSecret = ConfigurationManager.AppSettings["naa4e:twitter:sec"];
            if (!Globals.IsAnyNullOrEmpty(naaeTwitterKey, naaeTwitterSecret))
            {
                var twitterOptions = new TwitterAuthenticationOptions
                {
                    ConsumerKey = naaeTwitterKey,
                    ConsumerSecret = naaeTwitterSecret,
                    Provider = new TwitterAuthenticationProvider()
                    {
                        OnAuthenticated = (context) =>
                        {
                            context.Identity.AddClaim(new Claim("urn:tokens:twitter:accesstoken", context.AccessToken));
                            context.Identity.AddClaim(new Claim("urn:tokens:twitter:accesstokensecret", context.AccessTokenSecret));
                            return Task.FromResult(0);
                        }
                    }
                };
                app.UseTwitterAuthentication(twitterOptions);
            }

            // Configure social authentication: Facebook
            var naaeFbKey = ConfigurationManager.AppSettings["naa4e:fb:key"];
            var naaeFbSecret = ConfigurationManager.AppSettings["naa4e:fb:sec"];
            if (!Globals.IsAnyNullOrEmpty(naaeFbKey, naaeFbSecret))
            {
                var fbOptions = new FacebookAuthenticationOptions
                {
                    AppId = naaeFbKey,
                    AppSecret = naaeFbSecret,
                    Provider = new FacebookAuthenticationProvider
                    {
                        OnAuthenticated = (context) =>
                        {
                            // Gives you email, ID (to get profile pic), full name, and more
                            context.Identity.AddClaim(new Claim("urn:facebook:access_token", context.AccessToken));  
                            context.Identity.AddClaim(new Claim("urn:facebook:email", context.Email));
                            return Task.FromResult(0);
                        }
                    }
                };
                fbOptions.Scope.Add("email");
                app.UseFacebookAuthentication(fbOptions);
            }
        }
开发者ID:pachinko,项目名称:naa4e,代码行数:58,代码来源:Startup.cs


注:本文中的Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。