Home > front end >  Failed to generate jwt token for: com.apple.weatherkit.authservice for macOS
Failed to generate jwt token for: com.apple.weatherkit.authservice for macOS

Time:01-07

I'm trying to get my current weather in my location, however I get the following:

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

    class LocationManager: NSObject, ObservableObject{

        @Published var currentLocation: CLLocation?
        private let locationManager = CLLocationManager()

        override init(){
            super.init()
            locationManager.desiredAccuracy = kCLLocationAccuracyBest
            locationManager.distanceFilter = kCLDistanceFilterNone
            locationManager.requestAlwaysAuthorization()
            locationManager.startUpdatingLocation()
            locationManager.delegate = self
    
    }
}
extension LocationManager: CLLocationManagerDelegate{
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    
        guard let location = locations.last, currentLocation == nil else {return}
    
        DispatchQueue.main.async {
            self.currentLocation = location
        }
    }
    func locationManager(_ manager: CLLocationManager,
                     didFailWithError error: Error) {
        print( "location manager failed with error \(error)" )
    }
}
struct MainView: View {
    
    let weatherService = WeatherService.shared
    @StateObject private var locationManager = LocationManager()
    
    var body: some View {
        VStack{
            Text("Hello, World!")
        }.task(id: locationManager.currentLocation){
            do{
                if let location = locationManager.currentLocation{
                    let weather = try await weatherService.weather(for: location)
                    print(weather)
                }
            }catch{
                print(error)
            }
        }
        
    }
}

I have added weather kit capability to my app info and on the developer portal, what gives?

CodePudding user response:

You also need to enable it on the Apps services tab within your Edit your App ID Configuration on the developer dashboard - it is not obvious and was not outlined.

  • Related