使用有效令牌时“无效的OAuth访问令牌”

时间:2017-09-19 20:50:10

标签: oauth deezer

当尝试使用Deezer JS SDK访问/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

1 个答案:

答案 0 :(得分:1)

原来这是一个权限问题。我将权限更改为"basic_access,email,offline_access,manage_library,manage_community,delete_library,listening_history"并且有效。我不确定哪些返回的数据点与哪些权限相关联,但我的猜测是后端的一些权限已更改,文档中的示例尚未赶上。

相关问题