An error occurred when requesting user token: The operation couldn’t be completed. (SKErrorDomain error 7.)

I know that this is an error on Apple's side because I got source code from WWDC website: https://developer.apple.com/videos/play/wwdc2017/502/ and I downloaded this from the site: Interacting with Apple Music Content and I tried running this in the Xcode. Error is caused from completionHandler:


An error occurred when requesting user token: The operation couldn’t be completed. (SKErrorDomain error 7.)



completionHandler in question is found in func requestUserToken() from AuthorizationManager.swift file:


let completionHandler: (String?, Error?) -> Void = { [weak self] (token, error) in

print("print token: \(token)")

guard error == nil else {

print("An error occurred when requesting user token: \(error!.localizedDescription)")

return

}

guard let token = token else {

print("Unexpected value from SKCloudServiceController for user token.")

return

}

self?.userToken = token

print("print the user token: \(self?.userToken)")

/// Store the Music User Token for future use in your application.

let userDefaults = UserDefaults.standard

userDefaults.set(token, forKey: AuthorizationManager.userTokenUserDefaultsKey)

//userDefaults.synchronize()

if self?.cloudServiceStorefrontCountryCode == "" {

self?.requestStorefrontCountryCode()

}

NotificationCenter.default.post(name: AuthorizationManager.cloudServiceDidUpdateNotification, object: nil)

}


Source code is not modified and completionHandler does not seem to have any typos or structural errors that prevent it from working.


Am I in right place to relay this to Apple engineers or am I supposed to go somewhere else to get the attention of them?

Replies

We haven’t been able to reproduce this with a valid JWT on an account with an active Apple Music subscription. Can you please file a Radar with relevant logs and/or example requests to help us debug this issue?