Error Occurred when requesting user token (SKErrorDomain Code=7)

Trying to get the sample project to work (Adding Content to Apple Music). I've gotten a proper developer token and I can log in and see that I'm authorized by MPMediaLibrary and SKCloudServiceController. I also have both "Add to Cloud Music Library" and "Music Catalog Playback" capabilities.


When I try to return music data by clicking on the "Recents" tab, I get the error:


"No User Token was Specified. Request Authorization using the Authorization tab." I already have authorization in that tab as noted above.


From debugging, this is the code that errors out.


if SKCloudServiceController.authorizationStatus() == .authorized {

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

guard error == nil else {

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

return

}


error.localizedDescription is SKErrorDomain Code = 7. From my searches, this seems to be a can't connect to the cloud error? Though I can't confirm that..


Any idea why I would show SKCloudService authorized in one tab but yet it still seems to error out?


Thanks for the help,

Over a week and I can't get any progress on working on an AppleMusic integration because of this error. This is with both the example app and my own app. This is with a developer token that was previous working in both the example app and my own app. It stopped working, giving me: "An error occurred when requesting user token: The operation couldn’t be completed. (SKErrorDomain error 7.)"


Is there any reason a developer token that worked a week ago would no longer work? Is this error definitely on Apple's end. Is it getting fixed. I'm very frustrated. :-(

Have exactly the same issue, recently updated my iPad to iOS 11 beta 10. Bit late to the party but looks like the fix isn't working for me.

Ok, got past that error. I had actually created a developer token that expired, so that was my bad.


However, now I'm getting the following after doing the 'Request' flow in the example app:



2017-09-14 09:57:44.233673-0400 Adding-Content-to-Apple-Music[302:15257] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""

2017-09-14 09:57:44.234246-0400 Adding-Content-to-Apple-Music[302:15256] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"

I can search for songs, but clicking Play on them does nothing. Getting the same Code=9 error in my own app (with the same 'song won't play' behaviour).

Not working for me anymore either.. I'm using the new default code from the start of September but nothing will get me past error code 7.

Still having the same issue. Currently working on 10.3 and getting "The operation couldn’t be completed. (SKErrorDomain error 7.)". 😟 help me out

I figure out this Error. The code 7 it is because your generate a long expire time for your developer token.Try make is less 3 days.

True. I get the eror as soon as I try to set the expiration > 179 days!

It doesn't work for me.

Developer token works fine. (tested using REST API)

But I'm not enable to obtain user token.

Hello guys, I was having this same problem and I solved it.


I installed the iTunes Store App in the phone and now is fetching my user Token, also I initialized my cloudServiceController after the request authorization and not in the declaration of the variable.



SKCloudServiceController.requestAuthorization { [weak self] (authorizationStatus) in

switch authorizationStatus {

case .authorized:

print("Authorized")

self?.cloudServiceController = SKCloudServiceController()

self?.requestCloudServiceCapabilities()

self?.cloudServiceController?.requestUserToken(forDeveloperToken: MusicLibrary.libraryToken, completionHandler: self!.trytest)

default:

break

}

Code:

func fetchUserToken(developerToken : String, result: @escaping FlutterResult) {
print("iOS Developer Token", developerToken)
if #available(iOS 11.0, *) {
// let serviceController = SKCloudServiceController()
if SKCloudServiceController.authorizationStatus() == .authorized {
SKCloudServiceController().requestUserToken(forDeveloperToken: developerToken) { (userToken, err) in
if (err != nil) {
result(FlutterError(code: FlutterErrorCode.unavailable, message: "Error Encountered", details: err.debugDescription))
print("iOS fetchUserToken", err.debugDescription)
} else {
result(userToken)
}
}
}
}
else {
result(FlutterError(code: FlutterErrorCode.unavailable, message: "Not supported on iOS < 9.3", details: nil))
}
}

Error Log:

2019-02-01 13:56:16.576496+0530 Runner[327:12914] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-02-01 13:56:16.576616+0530 Runner[327:12914] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-02-01 13:56:16.578046+0530 Runner[327:13193] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-02-01 13:56:16.578133+0530 Runner[327:13193] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-02-01 13:56:16.581226+0530 Runner[327:13193] SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
iOS fetchUserToken Optional(Error Domain=SKErrorDomain Code=7 "(null)" UserInfo={NSUnderlyingError=0x28113c690 {Error Domain=SSErrorDomain Code=109 "(null)" UserInfo={NSUnderlyingError=0x28113c720 {Error Domain=SSErrorDomain Code=109 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store, SSErrorHTTPStatusCodeKey=401}}}}})


I am seeing this error once more, I validated the developer token, appId etc. double checked the developer token process.

Also this code seemd to work well a few days ago.


Please Advise.

I am seeing the exact same messages. The code 9 and cannot connect to Itunes store messages seem to be something new, I only started seeing them around early this year, did not see them before that. The code 7 user token seems to be independent of those and showed up for when I got a new developer token and had to generate a new user token. Huang Jobs suggestion worked for me, it went away when I changed the expiry to 3 days. Try setting your Developer token expiry to <= 3 days. if that works, see what maximum value works for you.

I still see the code 9 and cannot connect to Itunes store messages, but my app is working fine.

Error Occurred when requesting user token (SKErrorDomain Code=7)
 
 
Q