简体   繁体   中英

Trello API authentication not giving a valid user token if I disconnect

I integrated trello API to my dashboard on symfony 3.4.

When I go to my page for the first time, I have the authorize() function as a popup. When I accept, I have my token and my boards as return. For this case, all is good.

But if I disconnect the current user and come with another, this new user can access to the previous boards. It's like if the token stay the first user how come on the navigator.

Authorize()

Trello.authorize({
    name : 'Native Web',
    type : 'popup',
    expiration: "never",
    success: function () { onAuthorizeSuccessful(); },
    error: function () { onFailedAuthorization(); },
    scope: { write: true, read: true },
});

onAuthorizeSuccessful()

function onAuthorizeSuccessful() {
    var token = Trello.token();
    Trello.get('/members/me/boards/', successBoards, error);
}

The successBoards function processes the data.

So, do you have an idea? What am I doing wrong?

It's done, i have save the token on cookie. And i call Trello.authorize if the cookie doesn't exist.

I have added persist: false on this function. Like that the token is not save by the trello logic, but by my logic.

If someone is in my case :

Authorize()

 Trello.authorize({
            name: 'Native Web',
            type: 'popup',
            persist: false,
            expiration: "never",
            success: function () {
                onAuthorizeSuccessful();
            },
            error: function () {
                onFailedAuthorization();
            },
            scope: {write: true, read: true},
        });

onAuthorizeSuccessful()

function onAuthorizeSuccessful() {
    var token = Trello.token();
    $.cookie($.cookie('currentLog')+'TokenTrello', token, {expires: 365, secure: false});
    loadBoards();
}

loadBoards()

function loadBoards() {
    //Get the users boards
    $.get('https://api.trello.com/1/members/me/boards?key=' + API_KEY + '&token=' + $.cookie($.cookie('currentLog')+'TokenTrello'), successBoards);
}

Solved for me. Thanks

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