CredentialsError:即使设置了凭据,“配置中缺少凭据”

时间:2020-01-06 06:54:18

标签: javascript amazon-web-services amazon-cognito amazon-ses

我正在尝试使用未经身份验证的Cognito身份池,使用网络表单通过SES发送电子邮件。我使用的是纯香草JS,没有Node / jQuery / React。

function sendMessage(event) {
  var params = ...;

  AWS.config = new AWS.Config({
    region: 'us-west-2',
    credentials: new AWS.CognitoIdentityCredentials({
      // Unauthenticated pool for sending emails
      IdentityPoolId: 'us-west-2:foo'
    })
  });

  var SES = new AWS.SES({ apiVersion: '2010-12-01' });
  SES.sendEmail(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
  });
}

我已经将其设置为表单的onsubmit事件,但是每次提交时,我都会得到一个CredentialsError: "Missing credentials in config"

按照我的理解,我不必通过get()调用来下拉并显式设置访问密钥和秘密密钥。 Cognito和常规SDK文档中提供的所有代码示例均表明,您可以直接实例化服务对象并开始进行调用。正如我在this thread中发现的那样,也不应该存在任何比赛条件:

从v2.1.20开始,在提出请求时,证书被延迟获取。

我正在使用v2.597。我在这里想念什么?为什么这行不通?

0 个答案:

没有答案
相关问题