I've been reading up on communication between services/microservices.
The API Gateway authenticates the request and passes an access token (e.g. JSON Web Token) that securely identifies the requestor in each request to the services. A service can include the access token in requests it makes to other services.
And I'm passing access-token of a user to downstream services, So it looks more or less like this:
But what if a token is expired between microservices?
There are plenty of ways to solve this problem, those seem reasonable:
Validate access-token of a user and create short-lived JWT in API Gateway (kind of internal tokens)
Each microservice validates the JWT and generates its own JWT to communicates with other microservices according to scope rules
So we would have Auth service to validate or request tokens.
The questing is:
In order to be sure if token will be not expired during the journey through services we can just make a check in API Gateway layer: if a token is expired in n(~1) minutes reject it, so user have to use refresh token to obtain a new access token. It means token always will be valid for the time necessary to complete the request. What are pros and cons of this approach?