0

我想使用 shell 脚本和 curl 从 RingCentral 中提取呼叫数据。然后我会将其放入 ELK 中,以使用 Kibana 构建仪表板。但是,我不知道我在用 API 做什么。有没有人可以让我开始或一些示例代码来做到这一点?

我目前正在努力使用 curl 进行身份验证以获取令牌。目前,我不断收到不受支持的授权类型。我在 Sandbox 和“仅服务器无 UI”中设置了应用程序。

我已经使用 bash shell 从 Centos 7 机器上运行了它。

这是尝试过的代码:

curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token"; \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=<extension>&grant_type=password"

我将用户名和密码留空,因为我不确定那是什么。

输出如下:

{
  "error" : "invalid_request",
  "error_description" : "Unsupported grant type",
  "errors" : [ {
    "errorCode" : "OAU-250",
    "message" : "Unsupported grant type"
  } ]
}./rctest1.sh: line 2: -H: command not found
4

1 回答 1

0

;我已经能够重现您的错误,并且可以通过删除命令中 URL 后的分号 ( ) 来解决它。

解释

分号创建两个单独的 CLI 命令而不是一个,因此在您的调用中,您有两个请求。

- 您的要求 1

$ curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token"

- 您的要求 2

$ -H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=&grant_type=password"

- 你的回应 1

{
  "error" : "invalid_request",
  "error_description" : "Unsupported grant type",
  "errors" : [ {
    "errorCode" : "OAU-250",
    "message" : "Unsupported grant type"
  } ]
}

- 你的回应 2

./rctest1.sh: line 2: -H: command not found

- 测试命令

这是一个简单的测试,显示操作系统试图处理两个命令:

$ hello;world
-bash: hello: command not found
-bash: world: command not found

解决方案

- 工作要求

这是一个没有分号的工作请求:

$ curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token" \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=&grant_type=password"

- 工作响应

这是工作响应:

{
  "access_token" : "myAccessToken",
  "token_type" : "bearer",
  "expires_in" : 3600,
  "refresh_token" : "myRefreshToken",
  "refresh_token_expires_in" : 604800,
  "scope" : "Meetings VoipCalling Glip SubscriptionWebhook Faxes Contacts RingOut SMS",
  "owner_id" : "11111111",
  "endpoint_id" : "22222222"
}
于 2018-05-04T19:24:24.367 回答