Failed to generate JWT token error WeatherKit

Hi, I'm trying to implement WeatherKit for the first time and I am seeing this error when calling for the weather:

Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"

and

Encountered an error when fetching weather data subset; location=<+51.57750785,-2.08241362> +/- 6.55m (speed -1.00 mps / course -1.00) @ 11/01/2025, 11:50:45 Greenwich Mean Time, error=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors 2 Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"

I have: Enabled the WeatherKit capability in my iOS app in XCode Added Weatherkit to the AppID in the developer portal

Any suggestions what else I can check? I'm running iOS 18.2.1 on 15 ProMax with XCode 16.2

Answered by Frameworks Engineer in 821141022

Thanks for submitting it. Can you confirm you have enabled WeatherKit in the Developer Portal?

Under “Capabilities” as well as under “App Services”. It needs to be enabled both there as well as in Xcode.

Thanks for reaching out. Is this still happening? If so, could you please reproduce the issue while having Console.app open?

You can stream logs from your device/simulator and filter on your app's process and the log category called "AuthService". WeatherKit will output more specific error logs when it fails to generate an auth token and these logs should be visible in Console.app.

If you are not familiar with Console.app, please read more here: https://support.apple.com/guide/console/find-log-messages-and-activities-cnslbf30b61a/mac

Thanks for the prompt response - I have done as you have suggested, but I don't really understand what the logs are telling me, it's very noisy. I will include some sample error logs here in case they are relevant otherwise can you guide me as to what specifically to be looking for in the logs?

code-block
default	11:34:23.155379+0000	com.apple.weatherkit.authservice	Got JWT token response. requestIdentifier=4B51525F-930D-49EA-A33D-740B4E9B4D15, response=Optional(<NSHTTPURLResponse: 0xcf2390320> { URL: https://weatherkit.apple.com/v3/token } { Status Code: 401, Headers {
    "Access-Control-Allow-Origin" =     (
        "*"
    );
    "Content-Length" =     (
        0
    );
    Date =     (
        "Mon, 13 Jan 2025 11:34:23 GMT"
    );
    Server =     (
        Apple
    );
    "Strict-Transport-Security" =     (
        "max-age=31536000; includeSubdomains"
    );
    "content-security-policy" =     (
        "default-src 'self';"
    );
    "x-apple-origin" =     (
        "fdcbff05-73b4-3a53-948b-343caa55a40e"
    );
    "x-content-type-options" =     (
        nosniff
    );
    "x-frame-options" =     (
        SAMEORIGIN
    );
    "x-request-id" =     (
        "9f909c55-35c1-b5a9-3aee-015414f74658"
    );
    "x-xss-protection" =     (
        "1; mode=block"
    );
} })
error	11:34:23.155430+0000	com.apple.weatherkit.authservice	JWT Response not successful. requestIdentifier=4B51525F-930D-49EA-A33D-740B4E9B4D15
error	11:34:23.155690+0000	com.apple.weatherkit.authservice	Error while creating local signature. requestIdentifier=4B51525F-930D-49EA-A33D-740B4E9B4D15, error=<mask.hash: 'yc/OgnmKOD6eVUqD8KBuzg=='>
error	11:34:23.155869+0000	com.apple.weatherkit.authservice	Failed to generate token with error: invalidJWTResponse(Optional(<NSHTTPURLResponse: 0xcf2390320> { URL: https://weatherkit.apple.com/v3/token } { Status Code: 401, Headers {
    "Access-Control-Allow-Origin" =     (
        "*"
    );
    "Content-Length" =     (
        0
    );
    Date =     (
        "Mon, 13 Jan 2025 11:34:23 GMT"
    );
    Server =     (
        Apple
    );
    "Strict-Transport-Security" =     (
        "max-age=31536000; includeSubdomains"
    );
    "content-security-policy" =     (
        "default-src 'self';"
    );
    "x-apple-origin" =     (
        "fdcbff05-73b4-3a53-948b-343caa55a40e"
    );
    "x-content-type-options" =     (
        nosniff
    );
    "x-frame-options" =     (
        SAMEORIGIN
    );
    "x-request-id" =     (
        "9f909c55-35c1-b5a9-3aee-015414f74658"
    );
    "x-xss-protection" =     (
        "1; mode=block"
    );
} }))
default	11:34:23.156012+0000	com.apple.weatherkit.authservice	Releasing transaction: 15C13CA8-8BC4-4242-874A-17D954DACC7A for: com.apple.weatherkit.token.service
error	11:34:23.173398+0000	com.apple.weatherkit.authservice	misuse at line 142299 of [1b37c146ee]
error	11:34:23.173465+0000	com.apple.weatherkit.authservice	API call with unopened database connection pointer
default	11:34:23.193429+0000	com.apple.weatherkit.authservice	writeDBwithCachedResponse-ERROR: (_dbWriteConnection=0x1044bde70) insert SQL stmnt. is nil for storage: /private/var/mobile/Containers/Data/Application/90D7CCD7-96ED-4C28-BB58-411F6AAD15A2/Library/Caches/com.apple.weatherkit.authservice

Thanks for your reply with the detailed logs. Unfortunately we need more logs in order to diagnose the underlying issue.

Could you reproduce the issue and submit feedback through https://feedbackassistant.apple.com and attach a sysdiagnose from the device? Instructions can be found here: https://it-training.apple.com/tutorials/support/sup075/

Please reply back here with the feedback ID so we can look into it.

I have submitted the sysdiagnose, the reference is: FB16311482

Accepted Answer

Thanks for submitting it. Can you confirm you have enabled WeatherKit in the Developer Portal?

Under “Capabilities” as well as under “App Services”. It needs to be enabled both there as well as in Xcode.

Failed to generate JWT token error WeatherKit
 
 
Q