Weatherkit REST API is throwing 401 errors {'reason': 'NOT_ENABLED'}

I have a script which fetches observations from weatherkit rest API which was working fine till morning. Suddenly I am getting {'reason': 'NOT_ENABLED'} error. I haven't changed anything. My key still has access to weatherkit. Any idea what happened here?

I'm seeing the same thing on my end. No other changes on my side.

Everything in developer portal indicates my keys are active and I have I have decoded and validated JWTs that are being sent.

In addition, the Apple Developer Status page (https://developer.apple.com/system-status/) indicates no problems 🤷‍♂️

I am experiencing the same thing

Same issue, please help Apple developer team

Same thing, happening on some of the requests. They are also very slow, up to 30 seconds.

Same here

I have noticed that this happens only on when I'm on my local network, but it works fine when connected through a vpn. Could it be an issue with a network configuration of the WeatherKit REST API servers?

I have also noticed that this will happen when using Swift's URLRequests, but does not happen when calling the endpoints from Python using requests library.

same issue here. The issue happened first around 1/27 and I fixed it by giving it a new key file. Then it breaks again today(1/30).

This seems to happen super randomly, like some api requests go through and some does not.. This is really mind bothering...

If anyone figured out the root cause please share.

I've filed a support request on this one FB11969380

This is so annoying. Very random issue.

This issue seems to be getting worse, not better. It's clearly on Apple's side, it's well past time for someone on their team to comment.

I don't recall ever having this level of instability with the Dark Sky API.

The issue still persist. Current failure rate: Error rate:  37.0 %

Same issue over here, whereas DarkSky is doing just fine

just to confirm that this is still going on when using the REST API.

This is affecting us in 57.4% of our API calls. I have manually confirmed the validity of my JWT tokens, and besides, the same tokens work seconds after every failure. With Darksky ceasing service soon this is a rather urgent issue to be resolved. Is any Apple developer able to give an update on what is happening, and a timescale for a fix?

Same problem here with the REST API since a couple of weeks. We got errors on approx 50% of all WeatherKit calls too.

Need to start looking for an alternative APIs soon, this API does not seem fit for production use. Any recommendations?

PROBABLE SOLUTION TO THE 401 ISSUE WITH WEATHERKIT:

For everyone seeing this issue, what is likely the case is that you're generating the bearer token with a now timestamp and fixed (probably short) expiry. If you're rounding a millisecond timestamp to seconds to create that token you will likely see a certain percentage of requests with a JWT that is a few milliseconds too young to be valid yet (depending on exact time-shift with Apple's servers). Generate the token with a few seconds negative offset versus "now" and you'll be fine.

This worked like a charm for us.

An update. Seems like maybe @Hi_Thomas solution was a coincidence, as someone else suggested. I am getting 401 errors again starting today. Why is Apple not saying anything about this? They are on the boards answering other questions. But they ignore this issue that is clearly the biggest cause of concern. I'm happy if they say we devs are doing something wrong. But the silence is unprofessional. Here are things you can say:

  1. We are looking into it but don't know anything yet.
  2. We've looked into it, and everything is fine on our end
  3. We have isolate the root cause and are working on a fix, though we don't have a timeline for when we will deploy a fix.
  4. We decided not to look into it.

Even 4. is better than nothing.

same here, none of those solutions I can find work for me

Weatherkit REST API is throwing 401 errors {'reason': 'NOT_ENABLED'}
 
 
Q