chris barbalis vvvl mbbokk unsplash 5

I sought in Internet how to determine from Google response whether an access token is expired. I found no definitive answer.

So, finally I created an access token and waited for a hour to see the Google response when I try to use this token.

The Google response (with a partial list of HTTP headers) is below:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="", error=invalid_token
Content-Type: application/json; charset=UTF-8

Username/Password Authentication Failed.

A weird thing is that Google says that it is application/json but the response body is not a JSON.

So the only way is to check whether the response HTTP status is 401.