"Invalid grant_type parameter or parameter missing" Mailchimp OAUTH 令牌
"Invalid grant_type parameter or parameter missing" Mailchimp OAUTH token
我尝试了多种实现方式来连接到 Mailchimp OAuth API。以下是我当前产生错误的代码:
"Invalid grant_type parameter or parameter missing"
我已经尝试 x-www-form-urlencoded 内容类型,将 body 字符串化并更改 headers。
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/
一定有 header 或我遗漏的东西。
来自邮件黑猩猩文档示例(此处 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 形式编码 post 正文而不是 JSON。
我尝试了多种实现方式来连接到 Mailchimp OAuth API。以下是我当前产生错误的代码:
"Invalid grant_type parameter or parameter missing"
我已经尝试 x-www-form-urlencoded 内容类型,将 body 字符串化并更改 headers。
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/
一定有 header 或我遗漏的东西。
来自邮件黑猩猩文档示例(此处 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 形式编码 post 正文而不是 JSON。