Spotify API 对我在当前播放曲目请求中定位的请求做出禁止响应
Spotify API responds with forbidden to my seek to position in currently playing track request
对于我想到的一个小项目,我想更好地熟悉 Spotify API。一切顺利,直到我想尝试 seek to position in currently playing track 请求,该请求只需要 user-modify-playback-state 范围,当我发送请求时,服务器响应 403 禁止.
{ [WebapiError: Forbidden] name: 'WebapiError', message: 'Forbidden', statusCode: 403 }
值得一提的是,我正在使用 spotify-web-api-node 模块与 API 通信,但我尝试从 Postman 发送相同的请求,但出现了同样的问题。
我用这个功能来切换用户:
const switchToUser = (username, callback) => {
User.findOne({ username: username })
.then(user => {
if (user !== null) {
SpotifyApi.setRefreshToken(user.refreshToken);
SpotifyApi.refreshAccessToken()
.then(data => {
SpotifyApi.setAccessToken(data.body["access_token"]);
callback(); // Callback
})
.catch(err => console.log(err));
} else {
console.log("There's no user with that username in the database.");
}
})
.catch(err => console.log(err));
};
我的电话:
switchToUser("stelrin", () => {
SpotifyApi.seek(1569091982344).then(
() => console.log("done"),
err => console.log(err)
);
});
权限link:
查找函数:
Image
我尝试在 spotify-web-api-node docs 中查找搜索功能,但没有找到。
感谢您的宝贵时间。
您在没有付费的情况下尝试播放时可能会收到 403,但消息会显示 PREMIUM_REQUIRED,另一种可能是 Seek 的参数不正确, 仅支持 position_ms 和 device_id , 后者是可选的, 你可以尝试检查发送的内容Spotify 检查对 https://api.spotify.com/v1/me/player/seek 的请求是否正确
对于我想到的一个小项目,我想更好地熟悉 Spotify API。一切顺利,直到我想尝试 seek to position in currently playing track 请求,该请求只需要 user-modify-playback-state 范围,当我发送请求时,服务器响应 403 禁止.
{ [WebapiError: Forbidden] name: 'WebapiError', message: 'Forbidden', statusCode: 403 }
值得一提的是,我正在使用 spotify-web-api-node 模块与 API 通信,但我尝试从 Postman 发送相同的请求,但出现了同样的问题。
我用这个功能来切换用户:
const switchToUser = (username, callback) => {
User.findOne({ username: username })
.then(user => {
if (user !== null) {
SpotifyApi.setRefreshToken(user.refreshToken);
SpotifyApi.refreshAccessToken()
.then(data => {
SpotifyApi.setAccessToken(data.body["access_token"]);
callback(); // Callback
})
.catch(err => console.log(err));
} else {
console.log("There's no user with that username in the database.");
}
})
.catch(err => console.log(err));
};
我的电话:
switchToUser("stelrin", () => {
SpotifyApi.seek(1569091982344).then(
() => console.log("done"),
err => console.log(err)
);
});
权限link:
查找函数: Image
我尝试在 spotify-web-api-node docs 中查找搜索功能,但没有找到。
感谢您的宝贵时间。
您在没有付费的情况下尝试播放时可能会收到 403,但消息会显示 PREMIUM_REQUIRED,另一种可能是 Seek 的参数不正确, 仅支持 position_ms 和 device_id , 后者是可选的, 你可以尝试检查发送的内容Spotify 检查对 https://api.spotify.com/v1/me/player/seek 的请求是否正确