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


C# IAppBuilder.UseTwitterAuthentication方法代码示例

本文整理汇总了C#中IAppBuilder.UseTwitterAuthentication方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseTwitterAuthentication方法的具体用法?C# IAppBuilder.UseTwitterAuthentication怎么用?C# IAppBuilder.UseTwitterAuthentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAppBuilder的用法示例。


在下文中一共展示了IAppBuilder.UseTwitterAuthentication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            app.CreatePerOwinContext(() => new DurandalAuthDbContext());
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            //Enable Cors support in the Web API. Should go before the activation of Bearer tokens
            //http://aspnetwebstack.codeplex.com/discussions/467315
            app.UseCors(CorsOptions.AllowAll);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            // Enabling 3 components:
            // 1. Authorization Server middleware. For creating the bearer tokens
            // 2. Application bearer token middleware. Will atuthenticate every request with Authorization : Bearer header
            // 3. External bearer token middleware. For external providers
            app.UseOAuthBearerTokens(OAuthOptions);

            app.UseMicrosoftAccountAuthentication(
                ConfigurationManager.AppSettings["MicrosoftKey"],
                ConfigurationManager.AppSettings["MicrosoftSecret"]);

            app.UseTwitterAuthentication(
                ConfigurationManager.AppSettings["TwitterKey"],
                ConfigurationManager.AppSettings["TwitterSecret"]);

            app.UseFacebookAuthentication(
                ConfigurationManager.AppSettings["FacebookKey"],
                ConfigurationManager.AppSettings["FacebookSecret"]);

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

示例2: 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
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication( new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString( "/Account/Login" )
            } );
            app.UseExternalSignInCookie( DefaultAuthenticationTypes.ExternalCookie );

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

            app.UseTwitterAuthentication(
               consumerKey: "PqRSqRIrWw8EJty1Gat0ZA",
               consumerSecret: "gsElizO6qYGPA1RMApWdp1BpsmfvRYXXBWmd0hs8" );

            app.UseFacebookAuthentication(
               appId: "449783478408068",
               appSecret: "a058d3068f6b29bc0149e5987b9e823a" );

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

示例3: 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: "000000004C10DD37",
                clientSecret: "RYELs9crdp8Eebca5YeO0cQQBzbsyGN8");

            app.UseTwitterAuthentication(
               consumerKey: "LHpUEuCYelGiT1zYJrHTDw",
               consumerSecret: "VZnwWxOfzFv9K9FOrfirz2fhD47wgSMo5m41zV3Has");

            app.UseFacebookAuthentication(
               appId: "207117879494713",
               appSecret: "a9496a24c4a27bb5b3ecbb9805306afc");

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

示例4: 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
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

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

            app.UseTwitterAuthentication(
                consumerKey: "QBAhakLsIl794uEEAX8csF3tP",
                consumerSecret: "ML44lD3gjDWfF1VR2SRmYa8Ic0VPUEk9FwraEBs0iP3awfvKuS");

            app.UseFacebookAuthentication(
                appId: "523635924470241",
                appSecret: "ef29066fd82cb20e746b52c00c7e34a7");

            app.UseGoogleAuthentication(new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationOptions() {   ClientId = "122905730574.apps.googleusercontent.com", ClientSecret = "AjLf5P2WiGXIQrKqeTBRifAr" });
        }
开发者ID:Rajeshbharathi,项目名称:CGN.Paralegal,代码行数:26,代码来源:Startup.Auth.cs

示例5: 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
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie, isPersistent: true);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            string microsoftClientId = ConfigurationManager.AppSettings["microsoft_clientid"];
            string microsoftClientSecret = ConfigurationManager.AppSettings["microsoft_clientsecret"];
            if (microsoftClientId != null && microsoftClientSecret != null)
            {
                app.UseMicrosoftAccountAuthentication(microsoftClientId, microsoftClientSecret);
            }

            string twitterConsumerKey = ConfigurationManager.AppSettings["twitter_consumerkey"];
            string twitterConsumerSecret = ConfigurationManager.AppSettings["twitter_consumersecret"];
            if (twitterConsumerKey != null && twitterConsumerSecret != null)
            {
                app.UseTwitterAuthentication(twitterConsumerKey, twitterConsumerSecret);
            }

            string fbAppId = ConfigurationManager.AppSettings["facebook_appid"];
            string fbAppSecret = ConfigurationManager.AppSettings["facebook_appsecret"];
            if (fbAppId != null && fbAppSecret != null)
            {
                app.UseFacebookAuthentication(fbAppId, fbAppSecret);
            }

            app.UseGoogleAuthentication();
        }
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:35,代码来源:Startup.Auth.cs

示例6: 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: "Pbdf6cD0RgZO6WZmg7OLg",
               consumerSecret: "ALZDj07Uc5lWETyxGqV1SEDUc6RgyPV110asSsR7PI");

            app.UseFacebookAuthentication(
               appId: "1412821768932410",
               appSecret: "108ba83ee8303a68ea5ab04226786fb3");

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

示例7: 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);

            // 3rd party providers
            var microsoftAppId = ConfigurationManager.AppSettings["MicrosoftAppId"];
            var microsoftAppSecret = ConfigurationManager.AppSettings["MicrosoftAppSecret"];
            if (microsoftAppId != null && microsoftAppSecret != null)
                app.UseMicrosoftAccountAuthentication(microsoftAppId, microsoftAppSecret);

            var twitterAppId = ConfigurationManager.AppSettings["TwitterAppId"];
            var twitterAppSecret = ConfigurationManager.AppSettings["TwitterAppSecret"];
            if (twitterAppId != null && twitterAppSecret != null)
                app.UseTwitterAuthentication(twitterAppId, twitterAppSecret);

            var facebookAppId = ConfigurationManager.AppSettings["FacebookAppId"];
            var facebookAppSecret = ConfigurationManager.AppSettings["FacebookAppSecret"];
            if (facebookAppId != null && facebookAppSecret != null)
                app.UseFacebookAuthentication(facebookAppId, facebookAppSecret);

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

示例8: 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

示例9: 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
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

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

            app.UseTwitterAuthentication(
                consumerKey: OAuthConfiguration.TwitterAuthConsumerKey,
                consumerSecret: OAuthConfiguration.TwitterAuthConsumerSecret);

            app.UseFacebookAuthentication(
                appId: OAuthConfiguration.FacebookAuthAppId,
                appSecret: OAuthConfiguration.FacebookAuthAppSecret);

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
            {
                ClientId = OAuthConfiguration.GoogleAuthClientId,
                ClientSecret = OAuthConfiguration.GoogleAuthClientSecret
            });
        }
开发者ID:Malkiat-Singh,项目名称:BitBook23,代码行数:30,代码来源:Startup.Auth.cs

示例10: 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(WebsiteContext.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, Account>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            
            app.UseTwitterAuthentication(
               consumerKey: WebConfigurationManager.AppSettings["TwitterId"],
               consumerSecret: WebConfigurationManager.AppSettings["TwitterSecret"]);
            
            app.UseFacebookAuthentication(
               appId: WebConfigurationManager.AppSettings["FacebookId"],
               appSecret: WebConfigurationManager.AppSettings["FacebookSecret"]);
        }
开发者ID:tblue1994,项目名称:SoftwareEngineeringProject2015,代码行数:34,代码来源:Startup.Auth.cs

示例11: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.UseOAuthBearerAuthentication(AccountController.OAuthBearerOptions);

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            if (IsTrue("ExternalAuth.Facebook.IsEnabled"))
            {
                app.UseFacebookAuthentication(CreateFacebookAuthOptions());
            }

            if (IsTrue("ExternalAuth.Twitter.IsEnabled"))
            {
                app.UseTwitterAuthentication(CreateTwitterAuthOptions());
            }

            if (IsTrue("ExternalAuth.Google.IsEnabled"))
            {
                app.UseGoogleAuthentication(CreateGoogleAuthOptions());
            }
        }
开发者ID:twoems,项目名称:PoolCloud,代码行数:27,代码来源:Startup.cs

示例12: 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(
                new TwitterAuthenticationOptions
                {
                    ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
                    Provider = new LinqToTwitterAuthenticationProvider()
                });

            //app.UseTwitterAuthentication(
            //   consumerKey: ConfigurationManager.AppSettings["consumerKey"],
            //   consumerSecret: ConfigurationManager.AppSettings["consumerSecret"]);

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

            //app.UseGoogleAuthentication();
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:35,代码来源:Startup.Auth.cs

示例13: 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);

            app.UseTwitterAuthentication(
                new TwitterAuthenticationOptions()
                {
                    ConsumerKey = TwitterConsumerKey,
                    ConsumerSecret = TwitterConsumerSecret,
                    Provider = new TwitterAuthenticationProvider()
                    {
                        OnAuthenticated = async context =>
                        {
                            context.Identity.AddClaim(new Claim(TwitterAccessTokenClaimType, context.AccessToken));
                            context.Identity.AddClaim(new Claim(TwitterAccessTokenSecretClaimType, context.AccessTokenSecret));
                        }
                    }
                }
               );
        }
开发者ID:hossamdarwish,项目名称:AspNetIdentitySocialProfileImage,代码行数:28,代码来源:Startup.Auth.cs

示例14: 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: "lVAwXKGYmyt2xL8pdOyxLanMF",
               consumerSecret: "vMLRQy8vmyHK3XqAOxFyF5GdNYMakpkYJ9Bcw5c7BUVNFqcuRW");

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

            //app.UseGoogleAuthentication();
        }
开发者ID:BitsCorner,项目名称:TwitterManager,代码行数:27,代码来源:Startup.Auth.cs

示例15: ProcessSiginOption

 private static void ProcessSiginOption(IAppBuilder app, SigininOptionConfig signinConfig)
 {
     switch (signinConfig.SigninOption)
     {
         case SigninOption.MicrosoftAccount:
             app.UseMicrosoftAccountAuthentication(
                 clientId: signinConfig.IdOrKey,
                 clientSecret: signinConfig.Secret);
             break;
         case SigninOption.Twitter:
             app.UseTwitterAuthentication(
                consumerKey: signinConfig.IdOrKey,
                consumerSecret: signinConfig.Secret);
             break;
         case SigninOption.Facebook:
             app.UseFacebookAuthentication(
                appId: signinConfig.IdOrKey,
                appSecret: signinConfig.Secret);
             break;
         case SigninOption.Google:
             app.UseGoogleAuthentication(
                 clientId: signinConfig.IdOrKey,
                 clientSecret: signinConfig.Secret);
             break;
         default:
             break;
     }
 }
开发者ID:Cyricx,项目名称:dexcms-core,代码行数:28,代码来源:Authentication.cs


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