简体   繁体   中英

Trello API authentication not giving a valid user token

I'm using the Trello JS client to grab a token for the user. However it keeps giving me back the same token, even if I'm not logged into Trello in that browser.

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);
   });
}

Any ideas on how to troubleshoot?

The issue was that the authorize() method has an argument 'persist' that defaults to true. If it's true, it stores the first token returned in local storage and no longer actually authenticates after that.

So I added persist: false and it started working :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM