I am try to get user token for apple music API, i

2019-05-02 15:10发布

I am using first time apple music api in my IOS app. I have already generate developer token with the help of python commands.

i am getting error every time when request for the user token "An error occurred when requesting user token: The operation couldn’t be completed. (SKErrorDomain error 7.)"

my developer token look like as "esfd.................................................................................Mpo"

if #available(iOS 11.0, *)

{

 SKCloudServiceController().requestUserToken(forDeveloperToken: 
 developerToken, completionHandler: { (userToken, error) in

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

})

}

else 
{    

SKCloudServiceController().requestPersonalizationToken(forClientToken: developerToken, withCompletionHandler: { (userToken, error) in

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

})


}

Please anyone help me ....

2条回答
手持菜刀,她持情操
2楼-- · 2019-05-02 15:33

It is the problem of develop token. I fixed it by using https://github.com/pelauimagineering/apple-music-token-generator. At the beginning, i use another ruby generator to get develop token. I test ok by using curl -v -H 'Authorization: Bearer [developer token]' "https://api.music.apple.com/v1/catalog/us/songs/203709340", but also get (SKErrorDomain error 7.) in sample code. Now it is ok. The ruby generator doesn’t work with requesting user tokens:https://github.com/pelauimagineering/apple-music-token-generator/issues/4

查看更多
Ridiculous、
3楼-- · 2019-05-02 15:53

Ok i got it,

Main reason for that "SKErrorDomain error 7" error is your subscription plan.

If you are not subscriber of apple music and you want to get music user token then you always get same type of error.

查看更多
登录 后发表回答