We're using the JWT auth process from the googleapis module, which uses this module. For a while we've sporadically been getting strange Unexpected token < errors while trying to get an access token, and finally I traced it back here.
Specifically, it seems like Google Analytics' API will occasionally return 5xx error responses that look like this:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 502 (Server Error)!!1</title>
...
<p><b>502.</b> <ins>That’s an error.</ins>
<p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds. <ins>That’s all we know.</ins>
This module is attempting to parse the response as JSON and returning the parse error when it fails, while it should probably just return the original error, which is more informative.
I'll see if I can submit a pull request fixing this in the next day or two.
We're using the JWT auth process from the googleapis module, which uses this module. For a while we've sporadically been getting strange
Unexpected token <
errors while trying to get an access token, and finally I traced it back here.Specifically, it seems like Google Analytics' API will occasionally return 5xx error responses that look like this:
This module is attempting to parse the response as JSON and returning the parse error when it fails, while it should probably just return the original error, which is more informative.
I'll see if I can submit a pull request fixing this in the next day or two.