使用cURL通过OAuth 2.0和Filemaker连接到Xero时,Invalid_grant

问题描述 投票:0回答:1

我正在使用FileMaker Pro将数据库从使用OAuth 1.0a更新为2.0,以便与Xero一起使用,但是遇到了问题。

我可以成功授权该应用程序(步骤1)并解析返回的代码和状态。然后,我需要使用特定的标头和正文将代码发送回令牌端点(https://identity.xero.com/connect/token)。这就是我遇到的问题。

这里是需要的:包含以下内容的POST请求

标题1:

Authorization: "Basic " + base64encode(client_id + ":" + client_secret)

Header 2:

Content-Type: application/x-www-form-urlencoded

请求正文:

grant_type=authorization_code

&code=xxxxxx

&redirect_uri=https://redirecturl.com

[我在Filemaker中所做的是一个带有以下"Insert from URL"选项的cURL :(并且Xero令牌端点作为指定的URL)

"-X POST" &

" -H \"Content-Type: application/x-www-form-urlencoded\"" &

" -H \"Authorization: Basic "& Base64EncodeRFC (4648; token::client_id &":"& token::client_secret ) & "\"" &

" -d grant_type=authorization_code&code="&token::code&"&redirect_uri=https://redirecturl.com"

但是运行脚本时,它总是以错误,invalid_grant来响应。

我检查并确保99%的重定向网址在整个过程中都是一致的

我是cURL的新手,并假设我的语法中肯定有某些内容我无法弄清楚,并且对它的含义和任何帮助都非常感谢!

感谢堆

curl filemaker xero-api
1个回答
0
投票

尝试使用--data-urlencode卷曲选项代替-d。而且您可能想将每个查询参数放在cURL calc中自己的行中。

类似这样的东西:

"-X POST" &

" -H \"Content-Type: application/x-www-form-urlencoded\"" &

" -H \"Authorization: Basic " & Base64EncodeRFC (4648; token::client_id &":"& token::client_secret ) & "\"" &

" --data-urlencode \"grant_type=authorization_code\"" &
" --data-urlencode \"code=" & token::code & "\"" &
" --data-urlencode \"redirect_uri=https://redirecturl.com\""
© www.soinside.com 2019 - 2024. All rights reserved.