I am getting this error when requesting a user token with Music Kit:
Error Domain=SKErrorDomain Code=7 "(null)" UserInfo={NSUnderlyingError=0x281e94a20 {Error Domain=SSErrorDomain Code=109 "(null)" UserInfo={NSUnderlyingError=0x281e965e0 {Error Domain=SSErrorDomain Code=109 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store, SSErrorHTTPStatusCodeKey=401}}}}}
I also am getting a 401 error when sending a curl request with the correct code:
curl -v -H 'Authorization: Bearer [developer token]' "https://api.music.apple.com/v1/catalog/us/songs/203709340"
I have searched around endlessly and cannot find a solution. I have tried changing the dev token many times, so I'm pretty sure that's not the issue. Here is my code:
SKCloudServiceController.requestAuthorization { (status) in
if status == .authorized {
self.cloudServiceController.requestStorefrontCountryCode(completionHandler: { (response, error) in
if error == nil {
UserDefaults.standard.set(response!, forKey: "MusicKitCountryCode")
print("Country code")
print(response)
self.cloudServiceController.requestUserToken(forDeveloperToken: musicKitDevToken) { (responseString, error) in
if error == nil {
self.updateServiceTokens(token: responseString!)
print("should complete")
completion(true)
} else {
print("there was an error fetching user token: \(error!)")
}
}
} else {
print("error fetchin storefront country code: \(error!)")
}
})
} else {
print("cloud service controller not authorized`")
}
}