我正在尝试访问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)
我应该在哪里以及如何添加开发者凭证?
答案 0 :(得分:0)
在react-Native中,SDK无法访问系统上的文件。您可以在https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-browser.html
这样的浏览器中设置凭据