在使用Amazon Cognito和LinkedIn Learning xAPI时,可能会遇到“作用域”问题。
当使用AWS SDK for JavaScript调用Amazon Cognito的API时,需要在身份池实例化过程中指定"AllowUnauthenticatedIdentities":true属性,以便在访问xAPI时能够不受认证的限制。另外,需要在IAM用户的策略中添加相应的权限,使其能够访问相关API。
代码示例:
AllowUnauthenticatedIdentities: true,
IdentityPoolName: 'MyTemporaryIdentityPool'
};
添加IAM用户策略
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1495384637000",
"Effect": "Allow",
"Action": [
"cognito-sync:*",
"cognito-identity:*"
],
"Resource": [
"*"
]
}
]
}
注意:以上代码仅供参考,具体情况以实际开发为准。