Post

Replies

Boosts

Views

Activity

Reply to iPhone running warmer than normal under iOS 16 beta
This has a usual occurrence historically with developer betas, especially the earlier betas before optimisations are released across the later betas. It's strongly recommended to install developer betas on devices dedicated to testing, but if it's causing thermal throttles during development I recommend a decent desk phone stand to help cool the device, avoiding wireless charging.
Jun ’22
Reply to WeatherKit REST API Authentication
I was really hoping the session would be more informative, but they simply said "[you need to] create the header containing the fields and values described in the developer documentation", when the developer documentation literally has no mention that this API uses JWTs. @leemartin reached out to Novall on Twitter to ask when the REST API will be functional, but hasn't received a response yet. Twitter isn't allowed to be linked, but the text of the link is permitted: https://twitter.com/leemartin/status/1534214645128564737 Really excited to get cracking with this, but looks like it's half-baked at the moment.
Jun ’22
Reply to WeatherKit REST API Authentication
I've opened a feedback request (10140066) with the following: WeatherKit REST API documentation is missing authentication details The API documentation for WeatherKit's REST API is missing the authentication details that were mentioned during the session video. Several other engineers have also reported this via the forums, without any official response. To reproduce, visit https://developer.apple.com/documentation/weatherkitrestapi/get_api_v1_weather_language_latitude_longitude and observe the lack of details regarding authentication. I expect to be able to understand how to authenticate with this API from its documentation, but the documentation is missing, however, any reference to authentication is missing. I am not using a version of Xcode to encounter this issue. Would really appreciate a timeline from Apple for a resolution!
Jun ’22
Reply to WeatherKit REST API Authentication
@tanakasan1734 you legend, thank you for staying up till 2am working on this!! Thank you so much for putting this up as a YouTube video as well, really appreciate it! I've converted your JavaScript example into my native Ruby & included it below. For those still having issues with this API: of significant importance is setting up an "app" in Certificates, Identifiers & Profiles in addition to setting up the "key", so you have an "app ID" registered for WeatherKit in addition to the key being assigned access to it. I would imagine this has something to do with the upcoming billing for WeatherKit. Full annotated example from my lab notebook: # WeatherKit REST API: access example # With thanks to Simon of All The Code (Twitter: @allthecode_) require 'openssl' # stdlib require 'logger' # stdlib require 'http' # gem install http require 'jwt' # gem install jwt ## APPLE ID's (mine are examples) TEAM_ID = "TVVX2ENCS3" # Your Apple Developer "team ID", see https://developer.apple.com/account/#!/membership -> "Team ID" APP_ID = "net.rubynerd.weathervane" # Create an Identifier -> App ID -> App -> set Bundle ID -> App Services -> check WeatherKit -> Save, use Bundle ID here KEY_ID = "HC2L4UY9UW" # Create a Key -> set Key Name -> check WeatherKit, use Key ID here KEY_PATH = "/Users/rubynerd/Downloads/AuthKey_HC2L4UY9UW.p8" # Path to file downloaded from key creation above ## GEO VARS # Charing Cross, nominal centre of London LAT = "51.5081" LONG = "0.1248" TZ = "Europe/London" DATASETS = %w{currentWeather}.join(",") # Read the key path to create an ECDSA key p8 = OpenSSL::PKey::EC.new(File.read(KEY_PATH)) # Create a JWT for accessing WeatherKit jwt = JWT.encode({ iss: TEAM_ID, iat: Time.now.to_i, exp: Time.now.to_i + 3600, sub: APP_ID, jti: "#{TEAM_ID}.#{APP_ID}", }, p8, 'ES256', { kid: KEY_ID, id: "#{TEAM_ID}.#{APP_ID}", }) # Use httprb (https://github.com/httprb/http) to make the request to WeatherKit res = HTTP.use(logging: { logger: Logger.new(STDOUT) }).headers( "Authorization" => "Bearer #{jwt}", ).get "https://weatherkit.apple.com/api/v1/weather/en/#{LAT}/#{LONG}?dataSets=#{DATASETS}&timezone=#{TZ}" # Parse the response body from JSON to a Ruby Hash body = res.parse # Print the condition code puts "conditionCode: #{body["currentWeather"]["conditionCode"]}" # Print required attribution & link puts "data provided by Apple WeatherKit (#{body["currentWeather"]["metadata"]["attributionURL"]})" If you're translating the above from Ruby to another language, I've included an expired JWT you can paste into jwt.io's debugger: eyJraWQiOiJIQzJMNFVZOVVXIiwiaWQiOiJUVlZYMkVOQ1MzLm5ldC5ydWJ5bmVyZC53ZWF0aGVydmFuZSIsImFsZyI6IkVTMjU2In0.eyJpc3MiOiJUVlZYMkVOQ1MzIiwiaWF0IjoxNjU0ODU0NTU5LCJleHAiOjE2NTQ4NTQ1NjQsInN1YiI6Im5ldC5ydWJ5bmVyZC53ZWF0aGVydmFuZSIsImp0aSI6IlRWVlgyRU5DUzMubmV0LnJ1YnluZXJkLndlYXRoZXJ2YW5lIn0.7mGJZvce6D2JmbligmurJc0H4sMa_CwCwHBB4a5yoQvh9n7AljVOpDp7vHblWRG-DPtSqSFzOflM92otKkgQSw Between the JS and Ruby, this should be enough to close this. I'll leave the feedback request open to push for accurate documentation. Let me know if you have any issues with what's above, or DM me on Twitter if you need further assistance.
Jun ’22