Securing gRPC-based Microservices in .NET Core

In the last section, the CreateAuthorizedChannel method creates a GrpcChannel which uses an access token to set the Authorization header during requests. In this sample, I noticed that there was no logic for checking if the token is expired and then refreshing it if it is. I was wondering if there are any articles that show a best practice for doing this with CallCredentials and GrpcChannel class.

For example, is there a way for the GrpcChannel to validate the token before each request and then generate a new one if necessary?

I find this to be important because Auth0 limits the number of machine to machine tokens that can be generated each month. It would not be ideal to create a new one each time the program runs.