My customer is a company that has credentials for my webserver and I want him to let his end-users to call my API with JWT that I supply for him. this is the flow:
- The end-user asks for a web page from the customer's webserver
- If the end-user has no JWT for my webserver, the customer's server calls my API with his credentials and I give him a new JWT with an expiration of 1 hour
- The customer sends back the JWT to his end-user and stores it in localstorage / cookies
- The end-user can call my API with his JWT
- When the end-user gets status code 401 from my API since it expired, he calls the customer's webserver again to a specific endpoint to get a new JWT with an expiration of 1 hour for my API, and then he can call my API again.
I want your opinion about this flow, and to understand if it is reasonable. Is there a way to improve this flow? maybe the end-user should look for his token and if it expired, to avoid calling my API and skip on that part in order to short the round trip?