Reputation: 3
With my project using the API in ASP MVC using OAuth, it seems that access tokens expire after 1 day, Although her expiry date after 14 days. I checked my settings in Startup.Auth
enter code here
public partial class Startup { public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
public static string PublicClientId { get; private set; }
// 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(AppDataContext.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(
// consumerKey: "",
// consumerSecret: "");
//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");
//app.UseFacebookAuthentication(
// appId: "321201955415666",
// appSecret: "a4ebb10b8a5369c413c06ee7098449ac");
//app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
//{
// ClientId = "",
// ClientSecret = ""
//});
}
}
{ "access_token": "scQXJFrvyPqWMz0xYLnHnmJ1vOAUt8b1ptmOeCuNsFa5AX8FJkGzpZSiBFtQR93fVzOnkBcJV3R8l3sfw04Pchfm1sx41_Zpn4GIb9OxGc1A4EnGzvQ4IHqa-9zw-hayalvErg-ETExABn2a8qh0qvZHWhy1ggfa9VDwy8fJzjEY03dNbc_azPBg4IGHDvUfux2X6cwtWkXkt8wzDKxRxou4QRmR2VHc7lFcISoLtA0wjjEtjo10yyrZolcqL5JrE2T_uw1CTvVQYjdcCs2wderQKD0MrZE9d_ql2RY4sFfa0p2pmdgVgrw6z7vTejED5ofFRyxp0sKG7pHtk1FSjX81nQyyhCFZLXWlQhy_WFxUMhJUYEKO3gTaQH2hkp9GYf10rtlrgd1iO9_ltjf0smjioUiw_pUa-kBqrhQyXgpWaqsbiDZWCzam82_lg8ED610IYcULC2981iXiaacYZ3gHrkp32eSapKvPzmGGbOPMzxi5oLgXIQedrDsCb-39mQvh3Ln32HCATPqiUAcWcA", "token_type": "bearer", "expires_in": 1209599, "userName": "ashraf", "Id": "087ee3e3-692d-4ae2-b62d-00da3534bee8", ".issued": "Sat, 18 May 2019 21:09:54 GMT", ".expires": "Sat, 01 Jun 2019 21:09:54 GMT" }
Upvotes: 0
Views: 474
Reputation: 169
All Information that needs to store user information exists in token data, so using cookie authentication is not necessary, remove it and check your code may solve your problem.
Upvotes: 0