当尝试使用Deezer JS访问/user/me时,我一直得到错误代码300 (无效的OAuth访问令牌)。我的代码大多是从示例中复制的,所以我无法理解为什么会发生这种情况。我已经尝试在API调用中手动指定令牌,并通过HTTP直接访问API,而且还没有通过无效的访问令牌错误。我做错了什么?
index.html:
<!doctype html>
<html>
<body>
<div id="dz-root"></div>
<a href="#" id="dtest">Login</a>
<a href="#" id="lstat">Get Login Status</a>
<a href="#" id="getme">Me</a>
<script type="text/javascript" src="http://cdn-files.deezer.com/js/min/dz.js"></script>
<script src="js/index.js"></script>
</body>
</html>index.js:
DZ.init({
appId: "253122",
channelUrl: "http://mopho.local/deezer-channel.html",
});
document.getElementById("dtest").addEventListener("click", () => {
DZ.login(function(response) {
console.log("1",response);
}, {perms: 'basic_access,email'});
});
document.getElementById("lstat").addEventListener("click", () => {
DZ.getLoginStatus(function(response) {
console.log(response);
});
});
document.getElementById("getme").addEventListener("click", () => {
DZ.api('/user/me',
function(response) {
console.log("2",response);
}
);
});deezer-channel.html:
<script src="http://cdn-files.deezer.com/js/min/dz.js"></script>mopho.local在我的主机文件+ nginx中配置为指向127.0.0.1。
我的Deezer应用程序有以下配置:
Application domain: mopho.local
Redirect URL after authentication: http://mopho.local发布于 2017-09-20 00:18:12
这原来是一个权限问题。我将权限更改为"basic_access,email,offline_access,manage_library,manage_community,delete_library,listening_history",它起了作用。我不确定返回的数据点中哪些与哪些权限相关联,但我的猜测是在后端更改了一些权限,而文档中的示例还没有跟上。
https://stackoverflow.com/questions/46309555
复制相似问题