簡體   English   中英

即使我指定了授權,也需要“授權要求”

[英]“Authorization require” even though I specified Authorization

在以下代碼中,我為API的OAuth2指定了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]' }

在您的選項中,您具有屬性header但應為headers ,這就是忽略"Authorization"部分的原因。

此外,不確定uri是否為有效屬性,但可以肯定的是url

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM