本文整理汇总了C#中IAppBuilder.UseMicrosoftAccountAuthentication方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseMicrosoftAccountAuthentication方法的具体用法?C# IAppBuilder.UseMicrosoftAccountAuthentication怎么用?C# IAppBuilder.UseMicrosoftAccountAuthentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseMicrosoftAccountAuthentication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureAuth
// Para obtener más información para configurar la autenticación, visite http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// Permitir que la aplicación use una cookie para almacenar información para el usuario que inicia sesión
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);
// Quitar los comentarios de las siguientes líneas para habilitar el inicio de sesión con proveedores de inicio de sesión de terceros
// Microsoft => https://account.live.com/developers/applications
app.UseMicrosoftAccountAuthentication(
clientId: "000000004C111F35",
clientSecret: "deMeyaE3qw25PVxxH79ndrTfwyeVk9Ua");
// Twitter => https://dev.twitter.com/
app.UseTwitterAuthentication(
consumerKey: "ZfAxJLtSy18Vc3ueOOA76w",
consumerSecret: "EpEGdYKF2emLS6eouoPeiJe6tJi5C2pSOkBDnbUDKY");
// Facebook => https://developers.facebook.com/apps/
app.UseFacebookAuthentication(
appId: "562262000476246",
appSecret: "097b95d01c1f6942a3c08560c69a8848");
app.UseGoogleAuthentication();
}
示例2: ConfigureWebAuth
public void ConfigureWebAuth(IAppBuilder app)
{
//Utilisation de cookie pour stocker les informations sur les utilisateurs authentifiés
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
LoginPath = new PathString("/Account/Login"),
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
});
// Utilisation d'un cookie pour le stockage des info temporaires des utilisateurs authentifiés
// via un fournisseur externe
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Activation du fournisseur d'authentification Microsoft
app.UseMicrosoftAccountAuthentication(
clientId: "00000000481106FF",
clientSecret: "MqwDmwpeGTezV6o4sJdgVKIfZm76TZt6");
// Activation du fournisseur d'authentification Facebook
app.UseFacebookAuthentication(
appId: "636293909765104",
appSecret: "807a0a17eeaa20dabc1bd72f1be33775");
// Activation du fournisseur d'authentification Google
app.UseGoogleAuthentication();
}
示例3: 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();
}
示例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: "000000004C111DB7",
clientSecret: "KSzUymCU0bPhZ0HyQbtWz58pBU0sIsF0" );
//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");
//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");
//app.UseGoogleAuthentication();
}
示例5: 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();
}
示例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: "0000000040110865",
clientSecret: "sk6T9LprRnHlnk74IJmz6z5NcAjyGKtm");
//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");
app.UseFacebookAuthentication(
appId: "244418352318084",
appSecret: "f39b49a290337ef6d848723cea64507b");
app.UseGoogleAuthentication();
}
示例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);
// Uncomment the following lines to enable logging in with third party login providers
app.UseMicrosoftAccountAuthentication(
clientId: "000000004810BE56",
clientSecret: "bAORWpckUYsxBZACJUsiIxJNAE3r7S2x");
//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");
//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");
app.UseGoogleAuthentication();
}
示例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
// 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();
}
示例9: 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();
}
示例10: 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);
var context = System.Web.HttpContext.Current;
// Uncomment the following lines to enable logging in with third party login providers
app.UseMicrosoftAccountAuthentication(
clientId: WebConfigurationManager.AppSettings["MicrosoftAuthClientId"] ?? "1",
clientSecret: WebConfigurationManager.AppSettings["MicrosoftAuthClientSecret"] ?? "1");
//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");
//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");
app.UseGoogleAuthentication();
}
示例11: 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;
}
}
示例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
// 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();
}
示例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
// 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" });
}
示例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);
// 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();
}
示例15: 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(ApplicationDbContext.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, int>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager), getUserIdCallback: (id) => (id.GetUserId<int>()))
}
}
);
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);
// Uncomment the following lines to enable logging in with third party login providers
app.UseMicrosoftAccountAuthentication(
clientId: "0000000044168C24",
clientSecret: "rLRmutBi-lmK6LYFOpMhwLIqKjBYz0YQ");
//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");
app.UseFacebookAuthentication(
appId: "1508306016149534",
appSecret: "2663a9a27fa5af04c7192a35d9151a96");
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "117337387843-ggvs13ctb4j8t5v578hbkgijbaj05jt0.apps.googleusercontent.com",
ClientSecret = "z7pLeAJ71X0Wn3xcyfjNJr9S"
});
}