【发布时间】:2019-08-27 18:43:02
【问题描述】:
我正在尝试访问 AWS Cognito 的“adminAddUserToGroup”方法 来自我的本机应用程序。我想在他注册后立即将用户添加到特定组。
该方法的文档说“需要开发人员凭据”。 我在系统的 ~/.aws/credentials 中有我的凭据(AccessKey 和 SecretKey)。如何在我的代码中使用它?
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider(
{ region: regionId }
);
const params = {
GroupName: groupName,
UserPoolId: userPoolId,
Username: that.state.username
};
cognitoidentityserviceprovider.adminAddUserToGroup(
params,
(err, data) => {
if (err) console.log(err);
else {
console.log(data);
}
}
);
这会导致错误
CredentialsError: Missing credentials in config
at credError (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:245014:50)
at Config.getCredentials (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:245058:24)
at Request.VALIDATE_CREDENTIALS (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:245435:36)
at Request.callListeners (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:244218:28)
at Request.emit (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:244195:20)
at Request.emit (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:247081:26)
at Request.transition (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:246822:22)
at AcceptorStateMachine.runTo (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:247182:22)
at Request.runTo (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:246894:27)
at Request.send (blob:http://localhost:8081/6f586340-99cf-40d3-b978-de453021be50:246887:22)
我应该在哪里以及如何添加开发凭据?
【问题讨论】:
标签: react-native amazon-cognito aws-sdk-js