0

I am trying to create a very simple app using Apple's Apple Music API in Swift. To do this, I need to retrieve songs from Apple Music. I am trying to get a user token using this code

        SKCloudServiceController().requestUserToken(forDeveloperToken: "[DEV TOKEN HERE]") { (userToken, err) in
            if let e = err {
                print(e)
            }
            
                if let token = userToken {
                    print(token)
                }
            }

Right now I am just trying to print the token, but every time I call this function I am met with this error in console

Error Domain=SKErrorDomain Code=0 "An unknown error occurred" UserInfo={NSLocalizedDescription=An unknown error occurred}

I am confident that it is not my Dev Token because that usually throws a 'Cannot Connect to iTunes' error and I have tried substituting random strings for my dev token just to get the same error.

I've looked around but I cannot find an answer to this, has anyone else encountered it or have any idea how to fix it? Thank you!

P.S I am not too familiar with posting on Stack Overflow so if I made some mistake please let me know so I can correct it!

Ali Hachem
  • 31
  • 2
  • Were you able to fix this issue? Did changing the dev token work for you? I'm STILL having this issue and we're on iOS 14.4 now... I found others having problems such as this around 2 months ago. – Beau Nouvelle Mar 05 '21 at 07:08

1 Answers1

0

Same here. It worked before 14.2. Developer Token is valid, I checked Dev Center.

Nick Sorge
  • 21
  • 2
  • It's really getting on my nerves I haven't been able to continue on with my project – Ali Hachem Dec 09 '20 at 17:07
  • I fixed it by creating a new Music API Token in Dev Center and creating a new Developer Token with this script: [Link](https://github.com/pelauimagineering/apple-music-token-generator) – Nick Sorge Dec 16 '20 at 10:32
  • Thanks for the response! I tried that but am still getting the same error, all you did was make a completely new Music API Token? Also, when pasting the e8 code into the python script, did you leave it in 4 lines or did you make it 1? I’m still struggling with this problem – Ali Hachem Dec 16 '20 at 10:34
  • Yes, I just created a new music api token for my specific bundle id. Then I downloaded the .p8 file, opened it, copied the private key, pasted in the python script and run the script. In the console log was my new developer token. And also a example curl command to test the token. – Nick Sorge Dec 17 '20 at 12:03