# Token not Refreshing .Net core

**URL:** <https://devforum.okta.com/t/token-not-refreshing-net-core/16514>\
**Category:** Questions\
**Created:** [October 8, 2021, 9:07am UTC](https://devforum.okta.com/t/token-not-refreshing-net-core/16514 "2021-10-08T09:07:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![e14a39202dc4b4fea756](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@e14a39202dc4b4fea756](https://devforum.okta.com/u/e14a39202dc4b4fea756)\
**Post date:** [October 8, 2021, 9:07am UTC](https://devforum.okta.com/t/token-not-refreshing-net-core/16514/1 "2021-10-08T09:07:00Z")

</div>

Given the following auth setup

```auto
  services.AddAuthentication(options =>
            {
              options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
            })
            .AddCookie()
            .AddOpenIdConnect(options =>
            {
              options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.Authority = Configuration["OktaAuth:OktaDomain"] + "/oauth2/default";
              options.RequireHttpsMetadata = true;
              options.ClientId = Configuration["OktaAuth:OktaClientId"];
              options.ClientSecret = Configuration["OktaAuth:OktaClientSecret"];
              options.ResponseType = OpenIdConnectResponseType.Code;
              options.GetClaimsFromUserInfoEndpoint = true;
              options.Scope.Add("openid");
              options.Scope.Add("profile");
              options.Scope.Add("email");
              options.SaveTokens = true;
              options.TokenValidationParameters = new TokenValidationParameters
              {
                NameClaimType = "name",
                RoleClaimType = "groups",
                ValidateIssuer = true
              };
            });

```

And with refresh token enabled, and grace period set to 30 seconds.

I’m unsure as to how to make my okta token actually refresh, as when I remove myself from the application after the initial login, I seem to stay authenticated for a REALLY long time.

The okta middleware, takes a lot out of my hands which is great, but makes it extremely hard to know what it’s actually doing. I have no idea, if it’s even trying to refresh the token or anything. But it appears to never invalidate itself.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 10, 2024, 1:00am UTC](https://devforum.okta.com/t/token-not-refreshing-net-core/16514/2 "2024-02-10T01:00:30Z")

</div>

Closed on February 10, 2024, 1:00am UTC


