1

We are programmatically calling the PageSpeed Insights API for an internal list of websites. The majority of the time it works fine, but at seemingly random times we are getting the error "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential..." When the error occurs we log the url that was used for the request as well as the error. As a result I can copy the exact url that generated the error and paste it into a browser (or Postman), https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://www.xyzsite.com/&strategy=mobile&locale=en&key={validAPIkey} for instance, and get a valid response. The fact that the same API key is being used for all requests I know it's valid so I have no idea what might be causing this error. Has anyone else run into this? Does anyone have any idea what might be causing this error to occur on a seemingly random basis?

  • 1
    What rate are you querying at? It could be (unlikely but just offering an idea) that you are hitting a rate limit and it is misreporting the error. I mean, the rate limit is pretty high so you would really have to be hitting it hard. – GrahamTheDev May 20 '21 at 19:09
  • We are intentionally limiting it to 60/minute and 25k/day. – existentialist May 24 '21 at 15:12

1 Answers1

0

I also experience the same issue. As on page 5 to 10 API are called with same API key and credentials. Token is also not expired but it generate 401 randonly on different API. See attached imageenter image description here

Saima Gul
  • 89
  • 7