Node.js Sendgrid API:“文件”;提供的授权授权无效、过期或被撤销;

Node.js Sendgrid API:“文件”;提供的授权授权无效、过期或被撤销;,node.js,api,express,sendgrid,Node.js,Api,Express,Sendgrid,我已经翻遍了过去的栈柱,似乎没有任何东西能解决这个问题。我使用的是生成的API密钥(不是API密钥ID),我允许所有权限,我甚至尝试打开第二个帐户并从那里尝试。代码如下: // Create new mail object. var mail = new helper.Mail(); // Set 'from' for email. var from = new helper.Email("owner@site.com", "First Last"); mail.setFrom(from)

我已经翻遍了过去的栈柱,似乎没有任何东西能解决这个问题。我使用的是生成的API密钥(不是API密钥ID),我允许所有权限,我甚至尝试打开第二个帐户并从那里尝试。代码如下:

// Create new mail object.
var mail = new helper.Mail();

// Set 'from' for email.
var from = new helper.Email("owner@site.com", "First Last");
mail.setFrom(from)

// Set 'subject' for email.
mail.setSubject("SchemeBeam Email Verification");

// Create a new personalization, which will allow us to define
// an individual to send this email too, as well as define
// substitutions to use so we can replace a string, such as
// '%hash'%, in the email template with the real hash for this
// user.
var personalization = new helper.Personalization()
var to = new helper.Email("test1@example.com", "Example User");
personalization.addTo(to);

// Set hash substituion.
//var substitution = new helper.Substitution("%hash%", md5Hash);
//personalization.addSubstitution(substitution);

// Let's send it.
var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
var request = sg.emptyRequest({
  method: 'POST',
  path: '/v3/mail/send',
  body: mail.toJSON(),
});

sg.API(request, function(error, response) {
  // Handle the response here.
  console.log(response.statusCode);
  console.log(response.body);
  console.log(response.headers);
});
下面是错误:

{ errors: 
   [ { message: 'The provided authorization grant is invalid, expired, or revoked',
       field: null,
       help: null } ] }
{ server: 'nginx',
  date: 'Wed, 16 Nov 2016 17:45:14 GMT',
  'content-type': 'application/json',
  'content-length': '116',
  connection: 'close',
  'x-frame-options': 'DENY' }

可能重复的可能重复。。。确保您使用的是API密钥本身,而不是IDI指定的使用生成密钥的API密钥。我确实在使用API密钥。我理解,我只是确保我们对生成的密钥有一个共同的定义。在这种情况下,我建议联系SendGrid支持部门,因为我认为您的代码没有任何问题。