Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
JWT token usage

I am using IdentitySercer4 with my .net application. I have IDS running and dishing out JWT tokens, an API endpoint protected with JWT and a Website.

Q. My website goes to IDS to get the token and can now call the API endpoint. But what do I do next? Surely I don't go back to IDS for another token for every call? Do I save my JWT token - either Db or cookie? and then present it every time. When is the check carried out to see if the JWT token has expired so the client goes back to IDS to get a new token?

Thanks

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You cache your token in the client and present it in the Authorization header in every request. The resource server (your API) validates the token during every request. At first, it checks the signature under the token by using the public key (the token is signed by the private key only known to the Identity Server). If the signature is valid, then it checks other stuff like the expiration date. The public key is obtainable from the URI /.well-known/openid-configuration of your IdentityServer. The resource server (your API) shouldn't call this endpoint every request, it should cache the public key instead. If your API is written in .NET, you should consider using the default authentication middleware implementation and setting Authority to point to your IdentityServer, this way token validation will be working out of the box.

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddJwtBearer(options =>
    {
        options.Authority = "<IdentityServerAddress:Port>";
    })
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!