在以下代码中,我为 API 的 OAuth2 指定了 Authorization with Bearer。但我不断得到401 - authorization required
。我不知道为什么身份验证不起作用,我大摇大摆地尝试了它,爪子但一切都起作用了,但在 Node 端却没有。
let mailOpt = {
uri: "https://api.sendgrid.com/v3/contactdb/recipients",
method: "POST",
header: {
"Authorization": `Bearer ${account.SENDGRID_ACCESS_TOKEN}`
},
body: "[\n" +
" {\n" +
` \"email\": \"${response[0].email}\"\n` +
" }\n" +
"]"
}
当我打印出实际的mailOpt时,我得到了下面的信息。一切看起来都很好。
MAILopt { uri: 'https://api.sendgrid.com/v3/contactdb/recipients',
method: 'POST',
header:
{ Authorization: 'Bearer access_token' },
body: '[\n {\n "email": "voqes@inboxbear.com"\n }\n]' }