Hey everyone!
When I ask to a user to authorize my application to get his token using t.getRestApi().authorize(), I receive a authDeniedError, even when the user agree with the authorization. The popup closes before the token is stored.
This is my powerup structure:
connector.js:
"board-buttons": function (t, opts) {
return [
{
...
callback: (t) =>
t
.getRestApi()
.isAuthorized()
.then((isAuthorized) => {
if (isAuthorized) {
onBtnClick(t);
} else
return t.popup({
title: "Authorize your account",
url: "auth.html",
});
}),
condition: "edit",
},
];
},
auth.html
<html>
<head>
{% load static %}
<script src="https://p.trellocdn.com/power-up.min.js"></script>
<link rel="stylesheet" href="https://p.trellocdn.com/power-up.min.css" />
<style>
select {
height: 30px;
}
* {
text-align: center;
}
</style>
</head>
<body>
<div id="content">
<p>We need you to authorize first!</p>
<button id="authorize" type="submit" class="mod-primary">
Authorize
</button>
</div>
</body>
<script src="{% static 'js/auth.js' %}"></script>
</html>
const authBtn = document.getElementById("authorize");
authBtn.addEventListener("click", () => {
t.getRestApi()
.authorize({ scope: "read,write" })
.then(() => {
t.alert({
message: "You're authorized!",
});
})
.then(() => {
return t.closePopup();
});
});
I’m using a django application to serve the files.