用于访问aws lex的Web凭据的问题

时间:2017-08-30 21:30:42

标签: amazon-web-services amazon-s3 aws-cognito amazon-lex

我正在尝试从网页构建基本聊天机器人到AWS lex。我正在尝试关注此页面:https://aws.amazon.com/blogs/ai/greetings-visitor-engage-your-web-users-with-amazon-lex/

显然,有些东西我没有正确设置,但我不太了解它是什么。

我在S3存储桶中托管了一个网页。我可以访问该网页,我可以在其上输入问题,然后收到错误:POST https://cognito-identity.us-east-1.amazonaws.com/ 400(错误请求)

    // Initialize the Amazon Cognito credentials provider
    AWS.config.region = 'us-east-1'; // Region
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    // Provide your Pool Id here
        IdentityPoolId: 'us-east-1_XXXXXXXX',   // IdentityPoolId: 'us-east-1:12345678-abcd-1234-aaaa-123456789'
    });

    var lexruntime = new AWS.LexRuntime();
    var lexUserId = 'discoveryUser' + Date.now();
    var sessionAttributes = {};
    var p = AWS.config.credentials;
    for (var key in p) {
        if (p.hasOwnProperty(key)) {
            console.log(key + " -> " + p[key]);
        }
    }

Error: Missing credentials in config

expired -> true
chat.html:81 expireTime -> null
chat.html:81 accessKeyId -> undefined
chat.html:81 sessionToken -> undefined
chat.html:81 params -> [object Object]
chat.html:81 data -> null
chat.html:81 _identityId -> null
chat.html:81 _clientConfig -> [object Object]
chat.html:84 credentials: true,,,,[object Object],,,[object Object]

如果未经授权的用户可以访问此页面,我会很满意。它没有任何私密性。或者,我不清楚如何从我的头版进行身份验证。我需要提供表格吗?如果我需要创建登录页面,是否有任何示例显示如何将数据发送到cognito?我是否未能正确设置用户和组?

请指出正确的方向。感谢。

0 个答案:

没有答案