locked
Security token with time in Web Api RRS feed

  • Question

  • User-1350042179 posted

    Hi

    What is a good library to access to web api with security headers and tokens?

    I would like that the token only works 5 minutes.

    Tuesday, March 5, 2019 4:24 AM

All replies

  • User36583972 posted


    Hi neoaguil17,

    What is a good library to access to web api with security headers and tokens?

    I would like that the token only works 5 minutes.

    You can refer the following sample.

    Secure a Web API with Individual Accounts and Local Login in ASP.NET Web API 2.2
    https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/individual-accounts-in-web-api

    In StartupAuth.cs, the following code configures the OAuth2 authorization server. You can set AccessTokenExpireTimeSpan value is 5 mins.

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



    Best Regards

    Yong Lu

    Tuesday, March 5, 2019 6:59 AM