WeatherKit iOS SDK 401 network error

I'm following along to the WWDC WeatherKit session, and I keep getting this 401 network error that causes my app to crash on a fatal error. I have already created the proper Bundle App ID with WeatherKit enabled, and added the WeatherKit capability.

Here is my code:

private func getWeather() async -> Double {

        let weatherService = WeatherService()



        let syracuse = CLLocation(latitude: 33.6846, longitude: 117.8265)



        let weather = try! await weatherService.weather(for: syracuse)



        let temperature = weather.currentWeather.temperature

        return temperature.converted(to: .celsius).value

    }

Full error message:

2022-06-07 17:35:43.051776-0700 WWDC2022[56529:1296409] WWDC2022/WeatherView.swift:30: Fatal error: 'try!' expression unexpectedly raised an error: WeatherDaemon.WDSHMACJWTAuthenticatorService.Errors.invalidJWTResponse(Optional(<NSHTTPURLResponse: 0x6000018402c0> { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers {

    Connection =     (

        close

    );

    "Content-Length" =     (

        0

    );

    Date =     (

        "Wed, 08 Jun 2022 00:35:43 GMT"

    );

    Server =     (

        Apple

    );

    "Strict-Transport-Security" =     (

        "max-age=31536000; includeSubdomains"

    );

    "X-Apple-Origin" =     (

        "8961098f-b238-3714-ba44-5b569c861456"

    );

    "X-Cache" =     (

        "TCP_MISS from a23-219-38-54.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)"

    );

    "X-Content-Type-Options" =     (

        nosniff

    );

    "X-Frame-Options" =     (

        SAMEORIGIN

    );

    "X-REQUEST-ID" =     (

        "5156c5c7-d23b-4a66-a161-c8a9fb849c85"

    );

    "X-XSS-Protection" =     (

        "1; mode=block"

    );

} }))
Answered by Jevon_Mao in 716188022

Originally I thought the issue was I didn't wait long enough for App ID to register, but its been a while, and the error still persists.

Does anyone have WeatherKit working right now (or at any time after this post)? I'm using the REST API from a python service and it was working fine a few days ago. Now, with no changes on my side, I'm getting 401.

I suspect that Apple deployed something that either broke the service or changed the behavior.

The JWT I am sending looks exactly like what I was sending a few days ago that worked. I had an "jti" in the payload, that seemed to be required a few days ago. However even if I take that out, so the JWT looks exactly like the documentation, it still gives me a 401.

WeatherKit iOS SDK 401 network error
 
 
Q