我们开发了一个iOS应用程序,使用visual 2013 apache Cordova工具及其使用web API(ASP.net web API 2)进行身份验证服务器。 access_token失效日期默认设置为14天,但是,在几个小时后,此令牌将过期并发送未经授权的访问错误。 当前令牌和用户名存储在本地存储器中。access_token在几个小时内过期并发送未经授权的访问错误 - ASP.net web API
公共无效ConfigureAuth(IAppBuilder应用) { //配置分贝上下文和用户管理器使用每个请求 app.CreatePerOwinContext(ApplicationDbContext.Create)的单个实例; app.CreatePerOwinContext(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),
AllowInsecureHttp = true
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
}