AWS QuickSight 会话结束得如此之快
AWS QuickSight session ends so fast
我在使用 QuickSight 时遇到问题。我正在关注 documentation 如何实施它。
我添加了这些政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"quicksight:GenerateEmbedUrlForAnonymousUser"
],
"Resource": [
"arn:aws:quicksight:eu-west-1:myUserId:namespace/default",
"arn:aws:quicksight:eu-west-1:myUserId:dashboard/{{dashboardId-1}}",
]
]
}
}
还有这个:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::myUserId:role/QuickSightEmbeddingAnonymousPolicy"
}
}
我正在用 nodeJS 生成 embedUrl。
app.get("/", (req, res) => {
const experienceConfiguration = {
"Dashboard": {
"InitialDashboardId": "idOfDashboard"
}
};
quicksight.generateEmbedUrlForAnonymousUser({
'AwsAccountId': 'myUserId',
'Namespace': 'default',
'AuthorizedResourceArns': ["arn:aws:quicksight:eu-west-1:myUserId:dashboard/idOfDashboard"],
'ExperienceConfiguration': experienceConfiguration,
'SessionLifetimeInMinutes': 600
}, function (err, data) {
console.log('Errors: ');
console.log(err);
console.log('Response: ');
console.log(data);
})
这里生成 EmbedUrl
。当我将它复制粘贴到我的浏览器时,它会显示仪表板。但是当我将那么长 url 应用到我的 React 应用程序时,它不会显示它。我在前端使用这段代码:
useEffect(() => {
let dashboard
function onDashboardLoad(payload) {
console.log("Do something when the dashboard is fully loaded.", payload);
}
function onError(payload) {
console.log("Do something when the dashboard fails loading", payload);
}
function embedDashboard() {
var containerDiv = document.getElementById("embeddingContainer");
var options = {
url: "HERE_THE_EMBED_URL",
container: containerDiv,
height: "700px",
width: "1000px",
};
dashboard = QuickSightEmbedding.embedDashboard(options);
dashboard.on("error", onError);
dashboard.on("load", onDashboardLoad);
}
embedDashboard()
}, [])
它会给我这个错误:Message: "csrf token missing or not match."
我还尝试从前端生成这个 EmbedUrl(这是我最初的想法),但遗憾的是只收到 CORS 错误。我在这里尝试使用此代码:
const experienceConfiguration = {
"Dashboard": {
"InitialDashboardId": "myDashboardId"
}
};
const generateEmbedUrlForAnonymousUserParams = {
"AwsAccountId": "myUserId",
"Namespace": "default",
"AuthorizedResourceArns": ["arn:aws:quicksight:eu-west-1:myUserId:dashboard/myDashboardId"],
"ExperienceConfiguration": experienceConfiguration,
// "SessionLifetimeInMinutes": 600
};
const quicksightClient = new QuickSight({
credentials: {
accessKeyId: 'myAccesId',
secretAccessKey: 'mySecretKey'
},
region: "eu-west-1",
});
quicksightClient.generateEmbedUrlForAnonymousUser(generateEmbedUrlForAnonymousUserParams, function (err, data) {
if (err) {
console.log(err, err.stack);
// errorCallback(err);
} else {
const result = {
"statusCode": 200,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type"
},
"body": JSON.stringify(data),
"isBase64Encoded": false
}
}
});
我也在一些教程中看到 quicksight 的管理面板可能需要更改 https://eu-west-1.quicksight.aws.amazon.com/sn/admin 但是我无法访问此页面。也许我需要管理员的更多权限?
您需要确保嵌入 QuickSight 仪表板的域已在此处列入白名单 https://eu-west-1.quicksight.aws.amazon.com/sn/admin#embedding
如果您无权在此处添加域,则需要 QuickSight 管理员在此处添加域。
我在使用 QuickSight 时遇到问题。我正在关注 documentation 如何实施它。 我添加了这些政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"quicksight:GenerateEmbedUrlForAnonymousUser"
],
"Resource": [
"arn:aws:quicksight:eu-west-1:myUserId:namespace/default",
"arn:aws:quicksight:eu-west-1:myUserId:dashboard/{{dashboardId-1}}",
]
]
}
}
还有这个:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::myUserId:role/QuickSightEmbeddingAnonymousPolicy"
}
}
我正在用 nodeJS 生成 embedUrl。
app.get("/", (req, res) => {
const experienceConfiguration = {
"Dashboard": {
"InitialDashboardId": "idOfDashboard"
}
};
quicksight.generateEmbedUrlForAnonymousUser({
'AwsAccountId': 'myUserId',
'Namespace': 'default',
'AuthorizedResourceArns': ["arn:aws:quicksight:eu-west-1:myUserId:dashboard/idOfDashboard"],
'ExperienceConfiguration': experienceConfiguration,
'SessionLifetimeInMinutes': 600
}, function (err, data) {
console.log('Errors: ');
console.log(err);
console.log('Response: ');
console.log(data);
})
这里生成 EmbedUrl
。当我将它复制粘贴到我的浏览器时,它会显示仪表板。但是当我将那么长 url 应用到我的 React 应用程序时,它不会显示它。我在前端使用这段代码:
useEffect(() => {
let dashboard
function onDashboardLoad(payload) {
console.log("Do something when the dashboard is fully loaded.", payload);
}
function onError(payload) {
console.log("Do something when the dashboard fails loading", payload);
}
function embedDashboard() {
var containerDiv = document.getElementById("embeddingContainer");
var options = {
url: "HERE_THE_EMBED_URL",
container: containerDiv,
height: "700px",
width: "1000px",
};
dashboard = QuickSightEmbedding.embedDashboard(options);
dashboard.on("error", onError);
dashboard.on("load", onDashboardLoad);
}
embedDashboard()
}, [])
它会给我这个错误:Message: "csrf token missing or not match."
我还尝试从前端生成这个 EmbedUrl(这是我最初的想法),但遗憾的是只收到 CORS 错误。我在这里尝试使用此代码:
const experienceConfiguration = {
"Dashboard": {
"InitialDashboardId": "myDashboardId"
}
};
const generateEmbedUrlForAnonymousUserParams = {
"AwsAccountId": "myUserId",
"Namespace": "default",
"AuthorizedResourceArns": ["arn:aws:quicksight:eu-west-1:myUserId:dashboard/myDashboardId"],
"ExperienceConfiguration": experienceConfiguration,
// "SessionLifetimeInMinutes": 600
};
const quicksightClient = new QuickSight({
credentials: {
accessKeyId: 'myAccesId',
secretAccessKey: 'mySecretKey'
},
region: "eu-west-1",
});
quicksightClient.generateEmbedUrlForAnonymousUser(generateEmbedUrlForAnonymousUserParams, function (err, data) {
if (err) {
console.log(err, err.stack);
// errorCallback(err);
} else {
const result = {
"statusCode": 200,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type"
},
"body": JSON.stringify(data),
"isBase64Encoded": false
}
}
});
我也在一些教程中看到 quicksight 的管理面板可能需要更改 https://eu-west-1.quicksight.aws.amazon.com/sn/admin 但是我无法访问此页面。也许我需要管理员的更多权限?
您需要确保嵌入 QuickSight 仪表板的域已在此处列入白名单 https://eu-west-1.quicksight.aws.amazon.com/sn/admin#embedding 如果您无权在此处添加域,则需要 QuickSight 管理员在此处添加域。