I make many different api calls to google api using access_token
so I need to handle case when access_token
is expired and exchange refresh_token
to get new one.
What is the best way to do this?
I guess turn every API call with try{}catch(){}
block.
If an exception rise, in catch()
block I will make another API call to validate access_token
through https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={accessToken}
endpoint.
This is probably not a good idea to turn every API call to try() catch(){}
block and duplicate catch () logic.
How can i do it better?
P.S. I am using guzzle library for making API calls.