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


C# IAppBuilder.UseOAuthBearerTokens方法代码示例

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


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

示例1: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {            
            app.CreatePerOwinContext<IdentityUserManager>(IdentityUserManager.Create);

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/OAuth/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(5),                
                AllowInsecureHttp = true
            };

            app.UseOAuthBearerTokens(OAuthOptions);            
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "852925537385-9t4d8fg869kpi1dlm58v77277b70lc6e.apps.googleusercontent.com",
            //    ClientSecret = "078iMDZvE2JKYZc8-a5TeEey",
            //    Provider = new GoogleAuthProvider()
            //});
        }
开发者ID:TkachukOrest,项目名称:Catch-Me-If-You-Can,代码行数:26,代码来源:Startup.AuthConfig.cs

示例2: Configuration

        public void Configuration(IAppBuilder app)
        {
            // アプリケーションの設定方法の詳細については、http://go.microsoft.com/fwlink/?LinkID=316888 を参照してください
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // アプリケーションが Cookie を使用して、サインインしたユーザーの情報を格納できるようにします
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, UserAccount>(
                        validateInterval: TimeSpan.FromMinutes(20),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            // サード パーティのログイン プロバイダーを使用してログインしているユーザーに関する情報を一時的に格納するのに Cookie を使用します
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // アプリケーションがベアラ トークンを使用してユーザーを認証できるようにします
            app.UseOAuthBearerTokens(OAuthOptions);
            OAuthAuthenticationConfiguratorManager.ConfigureOAuthentication(app);
        }
开发者ID:kyasbal-1994,项目名称:linophi,代码行数:25,代码来源:Startup.cs

示例3: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCors(new CorsOptions {PolicyProvider = new CustomOwinCorsPolicyProvider()});

            // 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: ConfigurationManager.AppSettings.Get("OAuthMicrosoftKey"),
                clientSecret: ConfigurationManager.AppSettings.Get("OAuthMicrosoftSecret"));

            app.UseTwitterAuthentication(
                consumerKey: ConfigurationManager.AppSettings.Get("OAuthTwitterKey"),
                consumerSecret: ConfigurationManager.AppSettings.Get("OAuthTwitterSecret"));

            app.UseFacebookAuthentication(
                appId: ConfigurationManager.AppSettings.Get("OAuthFacebookKey"),
                appSecret: ConfigurationManager.AppSettings.Get("OAuthFacebookSecret"));

            app.UseGoogleAuthentication();
        }
开发者ID:robyvandamme,项目名称:angular.net,代码行数:28,代码来源: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)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.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
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = 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
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //    new TwitterAuthenticationOptions
            //    {
            //        ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
            //        ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"],
            //        BackchannelCertificateValidator = new Microsoft.Owin.Security.CertificateSubjectKeyIdentifierValidator(new[]
            //        {
            //            "A5EF0B11CEC04103A34A659048B21CE0572D7D47", // VeriSign Class 3 Secure Server CA - G2
            //            "0D445C165344C1827E1D20AB25F40163D8BE79A5", // VeriSign Class 3 Secure Server CA - G3
            //            "7FD365A7C2DDECBBF03009F34339FA02AF333133", // VeriSign Class 3 Public Primary Certification Authority - G5
            //            "39A55D933676616E73A761DFA16A7E59CDE66FAD", // Symantec Class 3 Secure Server CA - G4
            //            "4eb6d578499b1ccf5f581ead56be3d9b6744a5e5", // VeriSign Class 3 Primary CA - G5
            //            "5168FF90AF0207753CCCD9656462A212B859723B", // DigiCert SHA2 High Assurance Server C‎A 
            //            "B13EC36903F8BF4701D498261A0802EF63642BC3" // DigiCert High Assurance EV Root CA
            //        })
            //    }
            // );


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

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
开发者ID:docodo19,项目名称:Troop7_Day21_Blog_Example,代码行数:61,代码来源: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)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(SkyberryContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.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
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                // access tokens
                Provider = new ApplicationOAuthProvider(PublicClientId),
                // using short lived access tokens coupled with long lived refresh tokens
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(60),
                AllowInsecureHttp = true,

                // refresh tokens
                RefreshTokenProvider = new RefreshTokenProvider(),
                TokenEndpointPath = new PathString("/token"),
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);
        }
开发者ID:daniel-williams,项目名称:skyberry2016,代码行数:30,代码来源:Startup.Auth.cs

示例6: ConfigureAuth

        public void ConfigureAuth(IAppBuilder app)
        {
            app.CreatePerOwinContext(() => new EnergyNetworkDbContext());
              app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
              app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.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:htw-bui,项目名称:EnergieNetz,代码行数:32,代码来源:Startup.Auth.cs

示例7: ConfigureAuth

        // Pour plus d’informations sur la configuration de l’authentification, rendez-vous sur 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);

            // Autoriser l’application à utiliser des jetons de support pour authentifier les utilisateurs
            app.UseOAuthBearerTokens(OAuthOptions);

            // Supprimer les commentaires des lignes suivantes pour autoriser la connexion avec des fournisseurs de connexions tiers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

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

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

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

示例8: ConfigureAuth

        public static void ConfigureAuth(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider("self"),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),

                // TODO: In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

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

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

            // app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            // {
            //     ClientId = "",
            //     ClientSecret = ""
            // });
        }
开发者ID:kizisoft,项目名称:IofThings,代码行数:30,代码来源:AuthStartup.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: "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

示例10: ConfigureOAuthTokenGeneration

        private void ConfigureOAuthTokenGeneration(IAppBuilder app)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(InnoventoryDBContext.Create);

            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            app.UseCookieAuthentication(new CookieAuthenticationOptions() { LoginPath = new PathString("/account/login") });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);
        }
开发者ID:verveinfotech,项目名称:Innoventory,代码行数:25,代码来源:Startup.Auth.cs

示例11: ConfigureAuth

		// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
		public void ConfigureAuth(IAppBuilder app)
		{
			// Configure the application for OAuth based flow
			//PublicClientId = "self";
			//OAuthOptions = new OAuthAuthorizationServerOptions
			//{
			//	TokenEndpointPath = new PathString("/Token"),
			//	Provider = new ApplicationOAuthProvider(PublicClientId),
			//	AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
			//	AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
			//	AllowInsecureHttp = 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
			//app.UseMicrosoftAccountAuthentication(
			//    clientId: "",
			//    clientSecret: "");

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

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

			//app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
			//{
			//    ClientId = "",
			//    ClientSecret = ""
			//});
		}
开发者ID:uwe-e,项目名称:BSE.Tunes,代码行数:36,代码来源:Startup.Auth.cs

示例12: ConfigureAuth

 public void ConfigureAuth(IAppBuilder app)
 {
     app.UseCookieAuthentication(new CookieAuthenticationOptions());
     app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
     app.UseCors(CorsOptions.AllowAll);
     app.UseOAuthBearerTokens(OAuthOptions);
 }
开发者ID:alekseysukharev,项目名称:bank,代码行数:7,代码来源:Startup.Auth.cs

示例13: Configuration

        public void Configuration(IAppBuilder app)
        {
            var unity = UnityConfig.GetConfiguredContainer();
            var config = new HttpConfiguration();
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
            config.MapHttpAttributeRoutes();
            config.DependencyResolver = new UnityDependencyResolver(unity);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions
            {
                AllowInsecureHttp = true,
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                ApplicationCanDisplayErrors = true,
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                Provider = new OAuthProvider("self", () => unity.Resolve<IUserPasswordStore<User, Guid>>(), unity.Resolve<IPasswordHasher>()),
                TokenEndpointPath = new PathString("/Token"),
            });
            var settings = ConfigurationManager.AppSettings;
            app.UseMicrosoftAccountAuthentication(settings.Get("MicrosoftClientId"), settings.Get("MicrosoftClientSecret"))
               .UseTwitterAuthentication(settings.Get("TwitterConsumerKey"), settings.Get("TwitterConsumerSecret"))
               .UseFacebookAuthentication(settings.Get("FacebookAppId"), settings.Get("FacebookAppSecret"))
               .UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
               {
                   ClientId = settings.Get("GoogleClientId"),
                   ClientSecret = settings.Get("GoogleClientSecret")
               });

            app.UseWebApi(config);
            AutoMapperConfig.Configure();
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:33,代码来源:Startup.cs

示例14: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

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

            // 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: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
开发者ID:pplavetzki,项目名称:LanguageExchange,代码行数:36,代码来源:Startup.Auth.cs

示例15: 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: "",
            //    clientSecret: "");

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

            IFacebookAuthenticationFactory facebookAuthenticationFactory = new FacebookAuthenticationFactory();
            FacebookAuthenticationOptions facebookAuthenticationOptions = facebookAuthenticationFactory.CreateAuthenticationOptions();
            app.UseFacebookAuthentication(facebookAuthenticationOptions);

            GoogleOAuth2AuthenticationOptions googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = ConfigurationManager.AppSettings["oAuth2.Google.ClientId"],
                ClientSecret = ConfigurationManager.AppSettings["oAuth2.Google.ClientSecret"]
            };
            googleOAuth2AuthenticationOptions.Scope.Add("profile");
            googleOAuth2AuthenticationOptions.Scope.Add("email");

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


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