oauth 2.0 のトークンを使用して REST API を試すと、本文の下に空の結果 [] が返され、ヘッダーに OK-200 ステータス コードが表示されます。
私はボットを作成し、残りの API を curl + 基本認証と swagger でテストしましたが、正常に動作しました。oauth 2.0 と swagger トークンを使用して curl コマンドをテストしましたが、これも問題なく動作します。
テストするためにさまざまな設定を試しましたが、基本に固執するために:
カスタム アプリでボットを作成しました。スコープは「すべて」が選択され、TTL は「永久」です。
「READ_USER_PROFILE,WRITE_USER_PROFILE,READ_CONVERSATIONS,WRITE_CONVERSATIONS,READ_USER」というスコープで、REST 経由でトークンを要求し、正常に受け取りました。
「ALL」スコープが機能しないことに気付きました。「invalid_client、スコープ ::= [ALL] に対してアプリケーション null が有効になっていません」が返されますが、同じクライアントが上記のスコープのいずれも一緒にまたは単独で機能しなくても機能します。 「すべて」を除く。
テストしているREST APIに必要なスコープがあることを確認しました。たとえば、「/conversations」の「READ_CONVERSATIONS」などです。
401 やその他のエラー コードはまったく表示されず、200 のみです。
swagger によって生成されたトークンを使用して同じコマンドをテストしたところ、結果とともに本文文字列が返されました (つまり、このトークンは機能します)。
私はこれと同じ問題を Postman と PowerShell の Invoke-WebRequest/Invoke-RestMethod で再現しました。
関連しているかどうかはわかりませんが、「管理」>「OAuth アプリ」の下の Web アプリに「OAuth アプリ」オプションが存在しないことに気付きました。[OAuth アプリ] タブで、[設定] > [Circuit Labs] で [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"}
しかし、実際の出力は次のとおりです。[ ]