Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 926
jetlej Avatar asked Dec 05 '25 11:12

jetlej


1 Answers

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 :)

like image 53
jetlej Avatar answered Dec 06 '25 23:12

jetlej



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!