PageSpeed Insights API returning 401 error at seemingly random times - pagespeed

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?

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 image

Related

Cannot successfully make here map requests using my api key

I cannot get a success response using the example code shown in the here documentation: https://developer.here.com/documentation/routing/dev_guide/topics/request-constructing.html
I created a Freemium account and generated two each of JS and REST api keys. Regardless of which key I try, I keep getting errors that seem to change with each attempt:
Sometimes a 404
Sometimes a 502
Sometimes a 504
Sometimes a 403 with a message I might understand if it happened every time:
{
Message: "User: anonymous is not authorized to perform: es:ESHttpGet"
}
Sometimes a 200 with a page not found error message from something called
Platform's Radar
Sometimes a 302 that redirects to a login for Kibana using a Live Nation account
For reference, a specific request from the documentation that I have been trying:
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apikey={API_KEY}&waypoint0=geo!52.5,13.4&waypoint1=geo!52.5,13.45&mode=fastest;car;traffic:disabled
I am really not sure what is going on here.
On replicating the API call, it is resulting 200 every time. For reference find screenshot, please use correct APIkey

Data is not returned for every URL input

I am not getting the labels and other properties on all the URL's when using the Google Vision API. It randomly gives this error on some URL.
{'responses': [{'error': {'code': 7, 'message': "We're not allowed to access the URL on your behalf. Please download the content and pass it in."}}]}
As in, on some runs I don't see this error on the URL and get data, and on the other runs I see the error.
Are you trying to access an image on someone else's server? It's possible that they're throttling your access, so that the Vision API can't access the image each time. You may have to slow down your requests.

Can I test Linkedin's fullprofile permissions and fields in development cycle?

Linkedin has a whole slew of fields to pull them with their API. But they say they want you to apply for something before you can request the fields (see a screenshot below). My question is, can I query those fields during development to test my app? Now Linkein returns error, if I try to request them. And Linkedin doesn't say anything about it in their API docs.
InternalOAuthError: Failed to obtain request token
Here is a screenshot.
I still don't know the answer whether I can test the behavior during development.
However, with trial and error method I found what permissions generate error in Linkedin. Lol thing is that you can request fields from those permissions just fine (no error throws), but cannot request permissions.
Fields from forbidden permissions (do not throw even if permissions are omitted in a request):
['languages', 'date-of-birth', 'phone-numbers', 'im-accounts'],
Forbidden permissions that throw:
['r_fullprofile', 'r_contactinfo'],

Google Analytics Data Feed 400 Bad Request on First Request Only

I have an inherited VB6 program that runs each morning to download Google Analytics feed data for several clients. The process does the following:
Checks that my current OAuth 2.0 Access Token (saved in my database from yesterday) has not expired, and if so obtains a new one. Naturally, when the program runs for the first time each day it gets a new Access Token.
For each client, post a request for feed data.
Processes the XML data received from the Google server.
My problem is with step 2 above. The first post using the new Access Token always fails with a 400 Bad Request error. Making a second post using the exact same data always succeeds and my program can move to step 3.
Here is an example of my POST (with Client Id and Access Token in [ ] brackets):
https://www.google.com/analytics/feeds/data?
ids=ga%3A[Client Id]&
start-date=2016-01-10&
end-date=2016-01-10&
metrics=ga%3Asessions%2Cga%3Atransactions%2Cga%3AtransactionRevenue&
dimensions=ga%3Amedium%2Cga%3Asource%2Cga%3Akeyword&
filters=ga%3Asource%3D%3Dshopping&
access_token=[Access Token]
This has been occurring for several weeks.
The error description (Err.Description) from my code is "400 Bad Request". The entire response from the Google server (less HTML) is "400. That's an error. Your client has issued a malformed or illegal request. That's all we know."
Can anyone offer any suggestions as to why the first request fails, but subsequent requests don't? I have even built in a five minute delay between getting the new Access Token and making the first data request, but still get the 400 Bad Request Error.
Any help you can offer would be greatly appreciated.
Thanks.
Using Fiddler (thank you M Schenkel) I was able to finally track the source of the problem.
My VB6 program is using the IP*WORKS! SSL component from nsoftware. The form had a single HTTPS component that was being used for (1) getting a new Access Token, and then (2) for getting the feed data.
Fiddler showed that the second use of the component was using some of the parameters from the first use of it.
I added a second HTTPS component to the form so my feed data request would start off with a blank slate and it worked.
Thank you very much for your help!

ASP.net webservice 401 error for some services only

I have created a webservice in a ASP.net. All the access to the respective website is done through HTTPS. The service which I have added is only one among many others.
I am trying to access just for test purposes this service through Javascript (Ajax, json). The final target is actually Android.
I am getting the following message:
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
The main problem here is inconsistency: while my webservice in inaccessible, another previously written webservice is accessible. Another apparent inconsistency is that even if I tried a compromise solution by adding the needed methods to the accessible webservice, these methods themselves incur a 401 error.
So, my question is related to both "Why doesn't my webservice work" and "How is this supposed to work", with more emphasis on the latter.
Thank you.
Never mind !
Since I was oblivious to the depths of the code I was changing on our server, I did not know that the 401 error message is sent due to the way the code is organised. To access other services, I had to authenticate first through the authentication webservice.

Resources