使用 /token API 端点接收错误代码 1004
Receiving errorCode 1004 with /token API endpoint
oauth 令牌授予是否需要付费帐户?我尝试使用免费帐户和试用帐户进行以下操作。
发送 /token POST as documented 结果:
{
"errorCode": 1004,
"message": "You are not authorized to perform this action.",
"refId": "cd9hgzwmdduh"
}
我使用这些参数:
grant_type: authorization_code
code: <acquired from step 1. in oauth flow>
hash: <see below>
我通过以下命令行操作获取了 hash
参数:
export app_secret=<acquired from developer app profile.>
export code=<code acquired from step 1 in oauth flow.>
echo -n "$app_secret$code" | openssl dgst -sha256
这些是我在成功达到 Get Access Token 终点之前纠正的错误:
创建 SHA256 哈希时,我忘记在 app_secret
和 code
之间连接 |
。要发送的正确 sha256 哈希应该是:
echo -n "$app_secret|$code" | openssl dgst -sha256
Header 应该是:
Content-Type:application/x-www-form-urlencoded
而不是作为 url 查询参数发送,我应该作为 x-www-form-urlencoded 参数发送。
这里是 HTML 协议的全文:
POST /2.0/token HTTP/1.1
Host: api.smartsheet.com
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&client_id=<client_id>&code=<code from step 1 of oauth flow>&hash=<see above>
```
oauth 令牌授予是否需要付费帐户?我尝试使用免费帐户和试用帐户进行以下操作。
发送 /token POST as documented 结果:
{
"errorCode": 1004,
"message": "You are not authorized to perform this action.",
"refId": "cd9hgzwmdduh"
}
我使用这些参数:
grant_type: authorization_code
code: <acquired from step 1. in oauth flow>
hash: <see below>
我通过以下命令行操作获取了 hash
参数:
export app_secret=<acquired from developer app profile.>
export code=<code acquired from step 1 in oauth flow.>
echo -n "$app_secret$code" | openssl dgst -sha256
这些是我在成功达到 Get Access Token 终点之前纠正的错误:
创建 SHA256 哈希时,我忘记在
app_secret
和code
之间连接|
。要发送的正确 sha256 哈希应该是:echo -n "$app_secret|$code" | openssl dgst -sha256
Header 应该是:
Content-Type:application/x-www-form-urlencoded
而不是作为 url 查询参数发送,我应该作为 x-www-form-urlencoded 参数发送。
这里是 HTML 协议的全文:
POST /2.0/token HTTP/1.1
Host: api.smartsheet.com
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&client_id=<client_id>&code=<code from step 1 of oauth flow>&hash=<see above>
```