Purush0th commented on issue #25630:
URL: https://github.com/apache/superset/issues/25630#issuecomment-1865593410
Hi @cwegener
we are using 3.0.2. Also, to generate guest token from the backend I'm
creating a CSRF token which returns set-cookie response. But I'm not returning
the CSRF to the embedded SDK, only the guest token.
Could that be problem?
```
async function getCsrfToken() {
let config = {
method: 'get',
url: `${supersetBaseUrl}/security/csrf_token/`
};
var response = await axios.request(config);
console.log(response.headers);
const cookieName = "session";
const sessionCookie = (response.headers['set-cookie'])
.find(cookie => cookie.includes(cookieName))
?.match(new RegExp(`^${cookieName}=(.+?);`))
?.[1];
return [response.data, sessionCookie];
}
async function getGuestToken(user, dashboardId, appToken, csrfToken,
sessionCookie) {
console.log(sessionCookie, csrfToken);
try {
let data = JSON.stringify({
"user": user,
"resources": [
{
"type": "dashboard",
"id": dashboardId
}
],
"rls": []
});
let config = {
method: 'post',
url: `${supersetBaseUrl}/security/guest_token/`,
headers: {
'X-CSRFToken': csrfToken,
'Authorization': 'Bearer ' + appToken,
'Content-Type': 'application/json',
'Cookie': 'session=' + sessionCookie
},
withCredentials: true,
data: data
};
var response = await axios.request(config);
return response.data;
} catch (error) {
return "";
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]