SwiftUI WeatherKit returns HTTP status code 403

Trying to get weather data for a specific location and specific timezone. Generated Service identifier and Private Key, from Apple developer site. Then Generated public key Generated jwt token from jwt.io by keying in the payload, header, public, and private key.

Header
{
    "alg" : "ES256", // predefined
    "kid" : “keyid” , // key id created for WeatherKit
    "id"  : “developer_team_account_id.com.company_name.MyWeatherKit, 
    "typ" : "JWT"
}
Payload
{
    "iat" : 1710117942,
    "exp" :  1710204342, 
    "iss" : "developer_team_account_id", 
    "sub" : "com.company_name.MyWeatherKit
}

I

Then call this function:

 func getWeatherData(requestId: String,
             latitudeStr: String,
             longitudeStr: String,
             completion: @escaping (Bool) -> () ){

    var country = "US"
    var language = "en"
    var tz = "CST"
    
    let jwtToken = "token here...."
    
    
    let urlString:String = "https://weatherkit.apple.com/api/v1/availability/" + language + "/" + latitudeStr + "/" + longitudeStr + "?" + "country=" + country + "&" + "timezone=" + tz
    print("Apple weather urlString: \(urlString)")
    let weatherURL = URL(string: urlString)
    
    var request = URLRequest(url: weatherURL!)
    request.httpMethod = "GET"
    request.setValue("Bearer \(jwtToken)", forHTTPHeaderField: "Authorization")
    
    
    let dataTask = URLSession.shared.dataTask(with:weatherURL!) { [self] responseData, response, error in
        do {
            print(response as Any)
            print(error as Any)
            if let data = responseData {
                try DispatchQueue.main.sync { [unowned self] in
                    let decoder = JSONDecoder()
                    let jsonData = try decoder.decode(Top.self, from: data)
                    // parse data here
                    print(jsonData)
                    completion(true)
                }
            }
        }
        catch {
            print("error: \(error.localizedDescription)")
            completion(false)
        }
    } 
    dataTask.resume()
   
}

Gives response with code 403

Optional(<NSHTTPURLResponse: 0x280cbcf00> { URL: https://weatherkit.apple.com/api/v1/availability/en/29.928894042968750/-95.607747517125430?country=US&timezone=CST } { Status Code: 403, Headers {
"Access-Control-Allow-Origin" =     (
    "*"
);
Connection =     (
    close
);
"Content-Security-Policy" =     (
    "default-src 'self';"
);
Date =     (
    "Tue, 12 Mar 2024 02:52:18 GMT"
);
Server =     (
    Apple
);
"Strict-Transport-Security" =     (
    "max-age=31536000; includeSubdomains"
);
"X-Cache" =     (
    "TCP_MISS from a23-38-189-78.deploy.akamaitechnologies.com (AkamaiGHost/11.4.3-54729273) (-)"
);
"X-Content-Type-Options" =     (
    nosniff
);
"X-Frame-Options" =     (
    SAMEORIGIN
);
"X-REQUEST-ID" =     (
    "bac7e5dc-c5fd-6f85-263b-8f59b169cd2f"
);
"X-XSS-Protection" =     (
    "1; mode=block"
);
  } })

The URL I am passing is : https://weatherkit.apple.com/api/v1/availability/en/29.928894042968750/-95.607747517125430?country=US&timezone=CST

Am I calling the wrong URL? Or is Apple weather service down? I am at a loss to understand. I need some help and guidance

SwiftUI WeatherKit returns HTTP status code 403
 
 
Q