javascript - "Invalid grant_type parameter or parameter missing"Mailchimp OAUTH token

标签 javascript meteor mailchimp

我尝试了各种实现来连接到 Mailchimp OAuth API。以下是我当前产生错误的代码:

"Invalid grant_type parameter or parameter missing" 

我尝试过 x-www-form-urlencoded 内容类型,对正文进行字符串化并更改标题。

  let body = {
    "grant_type": "authorization_code",
    "client_id": Meteor.settings.public.mailchimp.clientId,
    "client_secret": Meteor.settings.private.mailchimp.secret,
    "redirect_uri": Meteor.settings.public.mailchimp.redirect_uri,
    "code": code,
  }

HTTP.call("POST",
        `https://login.mailchimp.com/oauth2/token`, {
          data: body,
          headers: {
            "Content-Type": "application/json",
            "Content-Encoding": "",
            "User-Agent": "oauth2-draft-v10"
          },
          npmRequestOptions: {
            "gzip": true //Required to read error
          }
        }

... Code continued

他们的文档没有说明我遗漏的任何明显内容 http://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-oauth2/

肯定有一个标题或我丢失的东西。

最佳答案

来自邮件 chimp 文档示例(此处 https://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-oauth2/ ):

curl --request POST \
--url 'https://login.mailchimp.com/oauth2/token' \
--data "grant_type=authorization_code&client_id={client_id}&client_secret={client_secret}&redirect_uri={encoded_url}&code={code}" \
--include

它需要 URL 形式编码的帖子正文而不是 JSON。

关于javascript - "Invalid grant_type parameter or parameter missing"Mailchimp OAUTH token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48988772/

相关文章:

javascript - 如何在带有 scaleTime 的条形图中使用 x 和宽度?

javascript - array push 函数向数组中添加一个空索引

angular - 使用 angular2 的 Mailchimp 注册表单

css - @font-face 在电子邮件模板中有效吗?

javascript - 我想帮助在 Angular 5 中将 Firebase 数据库对象更改为数组

javascript - 在 React JS 中从 Array 返回多个 HOC 组件

meteor - 如何在发布中将数组转换为游标?

javascript - MongoDB/Meteor/Export MONGO_URL 到部署的应用程序

javascript - 无法让 Meteor 与轻量级 JS 触摸库 Hammer.js 配合使用

c# - Mvc .Net 从异步方法中捕获异常