编辑23/08/2016 我想你是在cookie认证与身份
// 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))
}
});
这是Visual Studio中具有标识的默认配置。 我可以争论为什么它不是安全的好选择,但那不是重点。
你可以去白衣它的“邮递员”,但它的棘手 这是我要做的事:
- 请在您的登录页面的请求:
- 获取的反伪造令牌形式:
- 请登录页面上POST请求与以数据的形式这个post数据:
现在你的邮递员得到验证cookie,你可以请求Web API与[授权]标签
编辑
对于工具,你必须添加一个授权头。
- 围棋的头形式
- 添加的HTTP标头 “授权”
- 单击编辑按钮等瞧;)
screen shot
以前的答案被删除
这是用于基本身份验证,取决于您的身份验证机制 – Mathieu
我正在使用身份。我用上面的方法,但仍然得到认证错误,像这样http://prntscr.com/c908zb –
我添加一个方法去cookie认证。每次认证会话关闭时,您都必须这样做。我建议你切换到基于令牌的身份验证,如果你必须从例如电话应用程序使用你的网络API,例如。维护电话应用程序的cookie是一团糟;) – Mathieu