ios - 请求musickitusertoken时无法识别问题,curl请求也不起作用
问题描述
使用 Music Kit 请求用户令牌时出现此错误:
错误域=SKErrorDomain Code=7 "(null)" UserInfo={NSUnderlyingError=0x281e94a20 {错误域=SSErrorDomain Code=109 "(null)" UserInfo={NSUnderlyingError=0x281e965e0 {错误域=SSErrorDomain Code=109"无法连接到 iTunes Store" UserInfo={NSLocalizedDescription=无法连接到 iTunes Store, SSErrorHTTPStatusCodeKey=401}}}}}
使用正确代码发送 curl 请求时,我也收到 401 错误:
curl -v -H 'Authorization: Bearer [developer token]' "https://api.music.apple.com/v1/catalog/us/songs/203709340"
我无休止地四处寻找,找不到解决方案。我已经尝试过多次更改开发令牌,所以我很确定这不是问题。这是我的代码:
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`")
}
}
解决方案
推荐阅读
- java - 保存后休眠未设置自动生成的ID
- spring-data - 由于 ReadTimeoutException 调整 ReactiveElasticsearchClient
- react-native - 创建低版本 react-native 时出错
- react-native - react-native-image-crop-picker 相机或文件未打开 onpress
- c# - 如何将 int 写入 System.Span,即 int.Parse(span) 的反转?
- reactjs - 如何使用反应测试库测试带有钩子的反应组件
- c# - 如何使用 LINQ 使用泛型类型查询 [key] 属性?
- php - 为什么找不到我的 php 页面?我的 yaml 文件有问题吗?
- angular - 如何在角度类型js中隐藏图表linechartoption
- python - SQLAlchemy 迁移表已经存在