Trello API身份验证未提供有效的用户令牌

时间:2016-11-28 01:12:47

标签: javascript trello

我正在使用Trello JS客户端为用户获取令牌。然而,即使我没有在该浏览器中登录Trello,它也会一直给我回复。

Trello.authorize({
   name: "Task Slayer",
   type: "popup",
   interactive: true,
   expiration: "never",
   success: function () { onTrelloAuthorizeSuccessful(); },
   scope: { write: true, read: true },
});

// Save the token after success call
function onTrelloAuthorizeSuccessful() {
   var token = Trello.token();
   $.get('https://api.trello.com/1/members/me/boards?key=' + TRELLO_CLIENT_KEY + '&token=' + token, {}, function(data){
      console.log(data);
   });
}

有关如何排除故障的任何想法?

2 个答案:

答案 0 :(得分:4)

问题是authorize()方法有一个参数'persist',默认为true。如果是真的,它会存储在本地存储中返回的第一个令牌,之后不再进行实际身份验证。

所以我添加了persist: false,它开始工作了:)

答案 1 :(得分:0)

将其添加到您的网址:

&scope=read,write,account&response_type=token

赞:https://trello.com/1/authorize?expiration=never&scope=read,write,account&response_type=token&name=YourAppName&key=YourKey