Access token 获取Myob AccountRight API访问令牌错误

Access token 获取Myob AccountRight API访问令牌错误,access-token,myob,Access Token,Myob,我正在尝试从MYOB获取访问令牌。我进行的POST调用返回“400错误请求错误” 我在用“axios”打电话 我已经得到了我在POST通话中发送的数据中使用的访问码 这是我的密码 const config= { headers:{'Content-Type':"application/x-www-form-urlencoded"}} const data={ client_id:"xxxxxxxxxxxxxxxxxxxxxxx", client_secret:

我正在尝试从MYOB获取访问令牌。我进行的POST调用返回“400错误请求错误” 我在用“axios”打电话 我已经得到了我在POST通话中发送的数据中使用的访问码

这是我的密码

const config= { headers:{'Content-Type':"application/x-www-form-urlencoded"}}
const data={
         client_id:"xxxxxxxxxxxxxxxxxxxxxxx",
         client_secret:"xxxxxxxxxxxxxxxxxxxxx",
         scope:"CompanyFile",
         code: code,
         redirect_uri:"http%3A%2F%2Flocalhost%3A30002Fcallback",
         grant_type : "authorization_code"
         }

axios.post("https://secure.myob.com/oauth2/v1/authorize", data, config)
  .then((res) =>{
                 console.log ("response ...............", res
                 }
        )
  .catch((error) => {
                 console.error("Error here is ........",error)
                    }
        )

默认情况下,Axios会尝试将
数据
字段发布为JSON,这是不正确的

相反,您希望对它们进行url编码,并在HTTP正文中发布url编码的字符串。请参阅“示例调用”

这里有一个很好的例子,说明了如何对w/axios进行url编码

我还注意到,您的
redirect_uri
字段已经进行了url编码,因此尝试再次对其进行编码意味着您将得到类似
http%253A%252F%252Flocalhost
的错误结果。根据示例调用仔细检查URL编码,以确保没有意外地对某些字段编码两次。从内存中,访问代码已经进行了适当的编码,因此您可能需要在重新编码之前对其进行解码以使其正常工作