I'm trying (in Swift) to use CryptoKit to generate the required JWT for the Apple Music Web API, as documented (sort of) here.
But I'm getting 401s no matter what I try. I found some examples of generating JWTs online, but something isn't working here. I've set up my identifiers and gotten an API secret through my account in the dev portal. It's associated with an identifier requesting Music API access (I requested all three available Music-related capabilities).
For the secret, I'm using the long key string from the .p8 file I generated and downloaded from the dev portal.
Here's what I've tried:
struct APIToken
{
struct Header: Encodable
{
let alg = "HS256"
let kid: String
}
struct Payload: Encodable
{
let iss: String
let iat: String
let exp: String
}
static func tokenize(keyID: String, issuerID: String, secret: String) -> String
{
let privateKey = SymmetricKey(data: Data(secret.utf8))
let headerJSONData = try! JSONEncoder().encode(Header(kid: keyID))
let headerBase64String = headerJSONData.base64EncodedString()
let currUnixTime = Int(Date().timeIntervalSince1970)
let expUnixTime = currUnixTime + 5 * 2628288 // five months of seconds
let payloadJSONData = try! JSONEncoder().encode(Payload(iss: issuerID, iat: "\(currUnixTime)", exp: "\(expUnixTime)"))
let payloadBase64String = payloadJSONData.base64EncodedString()
let toSign = Data((headerBase64String + "." + payloadBase64String).utf8)
let signature = HMAC<SHA256>.authenticationCode(for: toSign, using: privateKey)
let signatureBase64String = Data(signature).base64EncodedString()
let token = [headerBase64String, payloadBase64String, signatureBase64String].joined(separator: ".")
print(token)
return token
}
}
I also tried making sure the base64 strings are URL-safe with this extension:
extension Data
{
func URLSafeBase64EncodedString() -> String
{
return base64EncodedString()
.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
}
}
but that made no difference.
All the documentation says is
A decoded developer token has the following format.
{
"alg": "ES256",
"kid": "ABC123DEFG"
}
{
"iss": "DEF123GHIJ",
"iat": 1437179036,
"exp": 1493298100
}
After you create the token, sign it with your MusicKit private key using the ES256 algorithm.
Am I not doing that? Any insight appreciated.
General
RSS for tagDelve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello,
I'm currently developing an emergency and security app for a client.
This app is designed to notify organisations and its users of emergency situations.
Our client has asked whether it’s possible to programmatically trigger the SOS Emergency feature on iOS.
Could you let me know if this functionality is available?
Many thanks!
Alex
When I open Iplaytv on my Apple TV it says refresh needed but I don’t know how
Hello.
I'm preparing transfer app now but don't understand identifier length.
reporence : https://developer.apple.com/documentation/sign_in_with_apple/transferring_your_apps_and_users_to_another_team
1 : xxxxxx.15fbexc6b31e41e78b891803a56b1axx.0247
2: xxxxxx.26ae9x5347f1f4fcebb3ae1b91807b5xx
number 1 is The team-scoped user identifier
number 2 is transfer identifier
but length is different so i scared
is it okay?
Topic:
App & System Services
SubTopic:
General
Good day. Installed Sequoia Developer Beta.
After that, the laptop started to behave incorrectly, programs over 1 GB stopped installing, updates were not installed, sometimes it rebooted spontaneously. Decided to roll back. With the help of another Macbook, I managed to install 14.6.1. Errors remained. Updates are not installed. Tried to restore through the recovery menu, error at 52 minutes, using a boot disk, the same error. What else can I do?
Mac Book Pro M1 16gb/2tb
Topic:
App & System Services
SubTopic:
General
iPhone mirroring is available from macOS 15.
When running an app with iPhone mirroring
Can I know whether the app currently being mirrored is running at the top of the Mac app or screen?
Or is there a way to know whether it is hidden by another app on the Mac or re-displayed?
If not, I hope it will be added in a future update.
And I hope there is an API that can tell whether the current app is connected to iPhone mirroring or not.
I am trying to parse CMSensorDataList in watchOS. The maximum batch of data is comprised of 30 minutes. The sampling rate is 50Hz, which makes it 90,000 records for 30 minutes. We iterate over each item and finally write the data to a CSV file. As this is a slow processing keeping in view the execution limits of watchOS, the process suspends when app goes to the background. This way, it takes too much time to parse a significant time data. My question is, is there a way we can serialize this CMSensorDataList as a whole and transfer it to the phone using WCSession? Or is there another effective way to achieve this?
Hi,
I would like to reset system window private picker alert with ScreenCapture kit. i can reset the ScreenCapture permission with tccutil reset ScreenCapture. but it does not reset the system window private picker alert. i tried deleting the application directory from container and it does not help. the system window private picker alert uses the old approval i gave and it does not prompt a new alert. How can i starta with fresh screencapture kit settings for an app in testing?
Thanks
So I have a button on a widget styled as seen below. I want this button to take up the entirety of the width, problem is, when it does so either using a frame(maxWidth: .infinity) or if I increase the horizontal padding, the button still only gets clicked if the user taps near the buttons center. Otherwise, it will open the app.
Relevant code:
Button(intent: Intent_StartRest() ){
Text("stop")
}
.buttonStyle(PlainButtonStyle())
.tint(.clear)
.padding(.vertical, 6)
.padding(.horizontal, 100)
.background(RoundedRectangle(cornerRadius: 30).fill(.button))
.foregroundStyle(.buttonText) // Just sets text color
.useAppFont(size: 18, relativeTo: .caption, weight: .bold) // Just sets font
Any pointers?
在watchOS11.5下,Apple watch无法加载天气。无论是否连接自己的iPhone均无法加载
Hello,
I have a question related to the public iTunes Search API: https://performance-partners.apple.com/search-api
Do all the books have an ISBN associated? I used to do queries like:
https://itunes.apple.com/lookup?isbn=9781501110368. That book is available on Apple Books here: https://books.apple.com/us/book/it-ends-with-us/id1052928247 and the endpoint above returns informations about it.
However for newer books like:
https://itunes.apple.com/lookup?isbn=9781419766954
https://itunes.apple.com/lookup?isbn=9781250288776
Nothing comes back anymore even if those books exist there. The url's for the 2 above are:
https://books.apple.com/us/book/hot-mess-diary-of-a-wimpy-kid-19/id6476554491
https://books.apple.com/mt/book/the-mirror/id6474420363
For newer books starting the beginning of September 2024, nothing seems to come back when you search them by ISBN.
Thanks
If I run an app with a message filter extension, it's triggered for all the prepaid unknown numbers and its not triggered for all the unknown postpaid numbers. Any idea, how to trigger for postpaid unknown numbers?.
I want to create a brush similar to a fountain pen, with a three-dimensional feel to the strokes and a distinct tip. Alternatively, is it possible to achieve this by modifying the configuration parameters of a fountain pen brush?
Hello,
I am unable to figure out how I tell the FamilyActivityPicker whether it should show apps installed on my personal device (to be used with AuthorizationCenter.shared.requestAuthorization(for: .individual)) or apps installed on my child’s device (authenticated their phone via AuthorizationCenter.shared.requestAuthorization(for: .child)).
Is there any parameter or SwiftUI modifier I need to apply?
Otherwise, how does the user or the app know which token belongs to them and which token belongs to their child’s device?
Radar: FB17020977
Thanks a lot for your help!
I'm using WeatherKit for my weather app built with SwiftUI. Even though the location is set in an area where the NWS is issuing weather alerts, WeatherKit randomly returns availability.alertAvailability as temporarilyUnavailable or unsupported, and the weatherAlerts is always nil.
Callerid name is not being updated in device recent calls when incoming call is received or outgoing call is initiated for a number stored in my app unless phone app is force quit and relaunched. Is there any way to sync or refresh the callerid to be displayed in recent calls even if phone app is in background ?
Topic:
App & System Services
SubTopic:
General
Is it possible to integrate a button in an app that displays advertisements to support charities -without offering any direct reward to the user?
Hello! What is the TTL for evaluation key(s) used in Live Caller ID feature on iOS client side? We would like to align our server-side key storage TTL with the iOS client implementation to optimize memory usage.
Would really appreciate your help on this.
Is there a way to distinguish physical mouse/keyboard input from remote control mouse/keyboard input on Mac? Or even better, is there a way to detect if my Mac is being remotely controlled?
How to uninstall/delete Voice Control on macOS so that I can test my app for the case when the initial use of Voice Control causes it to be downloaded from Apple? Is there a folder in the macOS System or Library to delete to force a re-download of Voice Control?
My macOS app uses the older NSSpeechRecognizer to handle speech commands, but to use NSSpeechRecognizer required authorization via [SFSpeechRecognizer requestAuthorization...]. I do this and on a macOS system it can trigger a download of Voice Control, the macOS feature. An alert appears with:
"A 390 MB download is required to use speech recognition features in MyApp. You may need to quit and open MyApp again after download completes."