gpt4 book ai didi

node.js - 如何在 Node.js Lambda 中使用 AWS 用户池函数?

转载 作者:太空宇宙 更新时间:2023-11-04 03:30:31 24 4
gpt4 key购买 nike

我正在尝试使用用户池注册用户,并使用并改编了示例 here 中的代码在我的 lambda 中。

我以正常方式引用AWS:

var AWS = require('aws-sdk');

并尝试引用现有用户池:

AWS.config.region = 'eu-east-1';

var poolData = {
UserPoolId : 'eu-west-1_xxxxxxx',
ClientId : 'xxxxxxx'
};

var userPool = AWS.CognitoIdentityServiceProvider.CognitoUserPool(poolData);

但我收到以下错误:

TypeError: AWS.CognitoIdentityServiceProvider.CognitoUserPool is not a function

我使用了错误的 SDK 吗? the setup page解释了 aws-cognito-sdk.min.js 如何成为完整 SDK 的变体,但仅引用 Cognito 身份服务,因此我认为完整 SDK 也将允许我访问它...有什么想法吗?

最佳答案

所以,我已经弄清楚了。首先,是的,您可以使用标准的 aws-sdk。这是代码:

var params = {
ClientId: 'xxxxxxxxxxxxxx',
Password: 'password',
Username: 'Ross',
UserAttributes: [
{
Name: 'email',
Value: 'email@email.com'
}
]
};
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.signUp(params, function(err, data) {
if (err) {
console.log(err, err.stack);
context.fail(err);
} else {
console.log(data);
context.succeed(data);
}
});

关于node.js - 如何在 Node.js Lambda 中使用 AWS 用户池函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38683802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com