add additional check for invalid token by parsing the JSON response