【问题标题】:Using Curl to pull down Call Log Data使用 Curl 下拉通话记录数据
【发布时间】:2018-10-14 04:16:07
【问题描述】:

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

我目前正在努力使用 curl 进行身份验证以获取令牌。目前,我不断收到不受支持的授权类型。我在沙盒中设置了应用程序和“仅服务器无 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

【问题讨论】:

  • 请提供一些您迄今为止尝试过的示例。
  • 我们可以使用更多信息,例如什么外壳、什么操作系统以及您已经尝试过的代码,以及带有错误消息的输出日志。你有没有在 RingCentral GitHub 存储库中探索过:github.com/ringcentral
  • 我正在编辑原始帖子。我还将根据您的帖子查看 github.com 站点。谢谢

标签: shell api curl oauth-2.0 ringcentral


【解决方案1】:

我已经能够重现您的错误,并且可以通过删除命令中 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"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-24
    • 1970-01-01
    • 2016-03-20
    • 1970-01-01
    相关资源
    最近更新 更多