0

我正在尝试使用 Client-Credentials Grant 流程(https://circuit.github.io/oauth.html#client_credentials)发布消息,但不断收到

'{"errorDescription":"n/a","errorCode":"500"}'

这不是很有用(标题中也没有有用的信息)

我正在使用以下 python 代码,使用 requests 库

import requests

conv_id = "conv-uuid-here"
client_id = "client-id-here"
client_secret = "client-secret-here"
token = requests.request("POST", "https://circuitsandbox.net/rest/v2/oauth/token",
                         headers={
                             "Content-Type": "application/x-www-form-urlencoded"
                         },
                         data={
                             "grant_type": "client_credentials",
                             "scope": "ALL",
                         },
                         auth=(client_id, client_secret)
                         ).json()["access_token"]

r = requests.request("POST", "https://circuitsandbox.net/rest/v2/conversations/{conv_id}/messages".format(conv_id=conv_id),
                 **{
                     "json": {
                         "content": "this is a test",
                         "convId": conv_id
                     },
                     "headers": {
                         "Authorization": "Bearer {}".format(token),
                         "Content-Type": "application/json"
                     }
                 })

因此,如果您使用从 swagger api 文档( https://circuitsandbox.net/rest/v2/swagger/ui/index.htmltoken = )检索到的令牌替换它就可以正常工作(但它是从登录用户发布的,而不是机器人)。

那么在使用不同的身份验证方法时是否有某些端点不起作用,如果是,我在哪里可以找到有关它的文档?(客户端凭据授予与隐式授予,我不能使用隐式授予,因为我没有重定向 url)

有什么方法可以从服务器获取有关此 500 错误的更多信息以帮助调试?

谢谢

4

0 回答 0