Spotify createPlaylistWithName 导致禁止错误
Spotify createPlaylistWithName results in forbidden error
我正在尝试使用 Spotify iOS SDK 创建播放列表,但收到以下错误:
Error Domain=com.spotify.ios-sdk Code=403 "forbidden" UserInfo=0x7fb9eb577cf0 {NSLocalizedDescription=forbidden}
这是我尝试创建播放列表的方式:
[SPTRequest playlistsForUserInSession:session callback:^(NSError *error, SPTPlaylistList *myPublicPlaylists) {
[myPublicPlaylists createPlaylistWithName:playlistName publicFlag:FALSE session:session callback:^(NSError *error, SPTPlaylistSnapshot *myRequestedPlaylist) {
if (error != nil) {
return;
}
success(myRequestedPlaylist);
}];
}];
我已验证会话有效并且从 playlistsForUserInSession 返回的 SPTPlaylistlist 是正确的。避免此错误的正确创建播放列表方法是什么?
根据 iOS SDK 版本的自述文件,"When connecting a user to your app, you must provide the scopes your application needs to operate. A scope is a permission to access a certain part of a user's account, and if you don't ask for the scopes you need you will receive permission denied errors when trying to perform various tasks."
在这种情况下,需要为 SPTAuthPlaylistModifyPrivateScope 和 SPTAuthPlaylistModifyPublicScope 之一(或两者)授予权限。
例如:
// Create SPTAuth instance; create login URL and open it
SPTAuth *auth = [SPTAuth defaultInstance];
NSURL *loginURL = [auth loginURLForClientId:kClientId
declaredRedirectURL:[NSURL URLWithString:kCallbackURL]
scopes:@[SPTAuthStreamingScope, SPTAuthPlaylistModifyPrivateScope, SPTAuthPlaylistModifyPublicScope]];
我正在尝试使用 Spotify iOS SDK 创建播放列表,但收到以下错误:
Error Domain=com.spotify.ios-sdk Code=403 "forbidden" UserInfo=0x7fb9eb577cf0 {NSLocalizedDescription=forbidden}
这是我尝试创建播放列表的方式:
[SPTRequest playlistsForUserInSession:session callback:^(NSError *error, SPTPlaylistList *myPublicPlaylists) {
[myPublicPlaylists createPlaylistWithName:playlistName publicFlag:FALSE session:session callback:^(NSError *error, SPTPlaylistSnapshot *myRequestedPlaylist) {
if (error != nil) {
return;
}
success(myRequestedPlaylist);
}];
}];
我已验证会话有效并且从 playlistsForUserInSession 返回的 SPTPlaylistlist 是正确的。避免此错误的正确创建播放列表方法是什么?
根据 iOS SDK 版本的自述文件,"When connecting a user to your app, you must provide the scopes your application needs to operate. A scope is a permission to access a certain part of a user's account, and if you don't ask for the scopes you need you will receive permission denied errors when trying to perform various tasks."
在这种情况下,需要为 SPTAuthPlaylistModifyPrivateScope 和 SPTAuthPlaylistModifyPublicScope 之一(或两者)授予权限。
例如:
// Create SPTAuth instance; create login URL and open it
SPTAuth *auth = [SPTAuth defaultInstance];
NSURL *loginURL = [auth loginURLForClientId:kClientId
declaredRedirectURL:[NSURL URLWithString:kCallbackURL]
scopes:@[SPTAuthStreamingScope, SPTAuthPlaylistModifyPrivateScope, SPTAuthPlaylistModifyPublicScope]];