当我使用我的 oauth 2.0 的令牌尝试 REST API 时,我不断在正文下返回空结果 [],并且标头中有 OK-200 状态代码。
我创建了一个机器人并使用 curl + 基本身份验证以及 swagger 测试了其余的 API,它们工作正常。我使用带有 swagger 令牌的 oauth 2.0 测试了我的 curl 命令,这也可以正常工作。
我尝试了不同的设置来测试,但要坚持一个基础:
我在自定义应用程序下创建了一个 Bot,范围为“全部”,TTL 为“永远”。
我通过 REST 成功请求并接收了我的令牌,范围如下:'READ_USER_PROFILE,WRITE_USER_PROFILE,READ_CONVERSATIONS,WRITE_CONVERSATIONS,READ_USER'。
我注意到“ALL”作用域不起作用,它返回“invalid_client,应用程序 null 未启用作用域 ::=[ALL]”,但同一个客户端在没有上述任何作用域的情况下一起工作或单独工作除了“全部”。
我确保我拥有我正在测试的 REST API 的必要范围,例如“/conversations”的“READ_CONVERSATIONS”
我根本没有收到任何 401 或其他错误代码,只有 200 个。
我使用 swagger 生成的令牌测试了相同的命令,并且返回带有结果的正文字符串(换句话说,这个令牌有效)
我已经用 Postman 和 PowerShell 的 Invoke-WebRequest/Invoke-RestMethod 复制了同样的问题。
不确定它是否相关,但我注意到 Web 应用程序中不再存在“OAuth 应用程序”选项:“管理”>“OAuth 应用程序”下的 webclient。“OAuth 应用程序”选项卡,在“设置”>“电路实验室”中启用“OAuth 应用程序”。
\\Requesting token:
curl -X POST https://circuitsandbox.net/oauth/token -d "client_id=myclientidhere&client_secret=myclientsecrethere&grant_type=client_credentials&scope=READ_USER_PROFILE,WRITE_USER_PROFILE,READ_CONVERSATIONS,WRITE_CONVERSATIONS,READ_USER" -i
{"access_token":"myaccesstokenhere","token_type":"Bearer","scope":["READ_USER_PROFILE","WRITE_USER_PROFILE","READ_CONVERSATIONS","WRITE_CONVERSATIONS","READ_USER"]}
\\Making request:
curl -i "https://circuitsandbox.net/rest/v2/conversations" -H "Authorization: Bearer myaccesstokenhere" -i
[]
\\\Full sample (-i parameter):
\\Requesting token:
curl -X POST https://circuitsandbox.net/oauth/token -d "client_id=myclientidhere&client_secret=myclientsecrethere&grant_type=client_credentials&scope=READ_USER_PROFILE,WRITE_USER_PROFILE,READ_CONVERSATIONS,WRITE_CONVERSATIONS,READ_USER" -i
HTTP/1.1 200 OK
Date: Sat, 22 Jun 2019 01:21:43 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 179
Connection: keep-alive
access-control-allow-origin: *
access-control-allow-credentials: true
access-control-allow-methods: GET, POST, DELETE, PUT, PATCH, OPTIONS
access-control-allow-headers: Accept, Accept-Language, User-Agent, Origin, Connection, Host, Accept-Encoding, Authorization, Content-Type, api_key, apiKey
ETag: W/"b3-K441G+yOERm+Qhj2E8VpkzO8ISg"
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=157680000; includeSubdomains; preload
{"access_token":"myaccesstokenhere","token_type":"Bearer","scope":["READ_USER_PROFILE","WRITE_USER_PROFILE","READ_CONVERSATIONS","WRITE_CONVERSATIONS","READ_USER"]}
\\Making request:
curl -i "https://circuitsandbox.net/rest/v2/conversations" -H "Authorization: Bearer myaccesstokenhere"
HTTP/1.1 200 OK
Date: Sat, 22 Jun 2019 01:25:37 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 2
Connection: keep-alive
access-control-allow-origin: *
access-control-allow-credentials: true
access-control-allow-methods: GET, POST, DELETE, PUT, PATCH, OPTIONS
access-control-allow-headers: Accept, Accept-Language, User-Agent, Origin, Connection, Host, Accept-Encoding, Authorization, Content-Type, api_key, apiKey
ETag: W/"2-l9Fw4VUO7kr8CvBlt4zaMCqXZ0w"
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=157680000; includeSubdomains; preload
[]
我希望输出包括请求的正文输出,例如
{"type":"COMMUNITY","convId":"5fad5fa4-1097-d66f-083a-3f129214e99f","participants":["5fad5fa4-1097-d66f-083a-3f129214e99f","5fad5fa4-1097-d66f-083a-3f129214e99f","5fad5fa4-1097-d66f-083a-3f129214e99f","5fad5fa4-1097-d66f-083a-3f129214e99f"],"topic":"YourCompany","creationTime":1560992185888,"modificationTime":1561143383261,"creatorId":"5fad5fa4-1097-d66f-083a-3f129214e99f","creatorTenantId":"5fad5fa4-1097-d66f-083a-3f129214e99f","description":"Default open conversation for YourCompanyHere"}
但实际输出是:[ ]