admin管理员组文章数量:1296246
async authenticateTrello() {
const authUrl = `;name=TrelloPlanner&scope=read,write&response_type=token&key=${TRELLO_APP_KEY}`;
const token = await new Promise((resolve) => {
const popup = window.open(authUrl, 'Trello Auth', 'width=800,height=800');
let tokenFound = false;
const interval = setInterval(() => {
try {
if (popup.closed && !tokenFound) {
clearInterval(interval);
resolve(null);
return;
}
if (popup.location.href.includes('/token/approve')) {
const preElement = popup.document.querySelector('pre');
if (preElement && preElement.innerText) {
tokenFound = true;
const token = preElement.innerText.trim();
clearInterval(interval);
popup.close();
resolve(token);
}
}
} catch (error) {
console.log(error)
}
}, 500);
});
if (token) {
console.log('Token received:', token);
this.trelloToken = token;
sessionStorage.setItem('trelloToken', token);
this.checkAuth();
} else {
console.error('Failed to authenticate with Trello');
}
}
When I try to authenticate I see a token in the popup in a pre text which has the token. The pop up has the approve URL but the code doesn't grab the token and I cannot figure out why.
I expect that the token is saved and stored to the local storage and the pop up is closed but the program doesn't close the popup.
I tried to log some URL locations and the URL location is correct.
本文标签: javascripttrello authenticate user for tokenStack Overflow
版权声明:本文标题:javascript - trello authenticate user for token - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741625485a2389057.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论