使用Ruby';第三方

使用Ruby';第三方,ruby,authentication,oauth-2.0,calllog,ringcentral,Ruby,Authentication,Oauth 2.0,Calllog,Ringcentral,我目前正试图为RingCentral编写一个数据提取应用程序,将CSV转储到AWS,作为数据仓库项目的一部分。我已经回顾了他们的一些文档,这些文档概述了如何使用密码流进行身份验证,但是根据文档中的示例,似乎缺少了一些内容 在“密码流”下列出的示例中,有一个从未提及的身份验证标头,其中包含的值由作者从无到有地提取出来,然后在下面的身份验证步骤中从未提及。我可以通过作用域“读取调用日志”验证我的应用程序是否满足私有的、仅服务器的要求。以下是我的设置的屏幕截图: [链接到图片,因为我没有足够的声誉…呃

我目前正试图为RingCentral编写一个数据提取应用程序,将CSV转储到AWS,作为数据仓库项目的一部分。我已经回顾了他们的一些文档,这些文档概述了如何使用密码流进行身份验证,但是根据文档中的示例,似乎缺少了一些内容

在“密码流”下列出的示例中,有一个从未提及的身份验证标头,其中包含的值由作者从无到有地提取出来,然后在下面的身份验证步骤中从未提及。我可以通过作用域“读取调用日志”验证我的应用程序是否满足私有的、仅服务器的要求。以下是我的设置的屏幕截图: [链接到图片,因为我没有足够的声誉…呃][2]

使用沙盒凭据和端点进行开发,以下是我迄今为止尝试的内容:

url = 'https://platform.devtest.ringcentral.com/restapi/oauth/token'
headers = {'Content-Type'=>'application/x-www-form-urlencoded'}
body = {:grant_type=>"password", :username=>"13133982093", :password=><OUR_SANDBOX_PASSWORD>}
resp = HTTParty.post(url, headers: headers, body: URI.encode_www_form(body))
然后我们通过执行以下操作将令牌信息存储为哈希:
token\u hash=client.token.to\u hash

哈希的示例如下所示:

{"token_type"=>"bearer", "refresh_token_expires_in"=>604800, 
 "scope"=>"ReadCallLog", "owner_id"=>[COMPANY's OWNER_ID], 
 "endpoint_id"=>"N0UV835BQ2C_Bz2ofJA1Eg", 
 :access_token=> [REMOVED FOR SECURITY],
 :refresh_token=> [REMOVED FOR SECURITY], 
 :expires_at=>1498081681} 
但是,现在我无法执行2个操作:简单的身份验证请求或令牌刷新

正在尝试简单的
呼叫日志
请求: 获得一个错误:

 #<HTTParty::Response:0x7fdf2b0ae800 parsed_response={"errorCode"=>"InvalidParameter", "message"=>"Resource for parameter [accountId] is not found", "errors"=>[{"errorCode"=>"CMN-102", "message"=>"Resource for parameter [accountId] is not found", "parameterName"=>"accountId"}], "parameterName"=>"accountId"}, @response=#<Net::HTTPNotFound 404 Not Found readbody=true>, @headers={"server"=>["nginx/1.10.2"], "date"=>["Wed, 21 Jun 2017 21:39:58 GMT"], "content-type"=>["application/json;charset=UTF-8"], "content-length"=>["290"], "connection"=>["close"], "rcrequestid"=>["2b66c9d6-56ca-11e7-b418-005056bb26b9"], "routingkey"=>["SJC11P01PAS02"], "x-error-id"=>["2b66c9d6-56ca-11e7-b418-005056bb26b9"], "content-language"=>["en-US"], "x-rate-limit-group"=>["heavy"], "x-rate-limit-limit"=>["10"], "x-rate-limit-remaining"=>["9"], "x-rate-limit-window"=>["60"]}>
#<HTTParty::Response:0x7fdf3055d8d8 parsed_response={"error"=>"invalid_client", "error_description"=>"Invalid client: ", "errors"=>[{"errorCode"=>"OAU-153", "message"=>"Invalid client: ", "parameters"=>[{"parameterName"=>"client_id", "parameterValue"=>""}]}]}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @headers={"server"=>["nginx/1.10.2"], "date"=>["Wed, 21 Jun 2017 22:16:07 GMT"], "content-type"=>["application/json;charset=utf-8"], "transfer-encoding"=>["chunked"], "connection"=>["close"], "x-application-context"=>["application:8080"], "content-language"=>["en"], "www-authenticate"=>["Bearer realm=\"RingCentral REST API\", error=\"invalid_client\", error_description=\"Invalid client: \""], "rcrequestid"=>["3958edb2-56cf-11e7-8758-005056bb26b9"], "aceroutingkey"=>["sjc11-c01-ace01.c83d65c2-46d3-11e7-ab8e-005056a73f60"], "x-server-name"=>["sjc06-c01-hlb01"], "x-request-time"=>["0.000"], "x-upstream-server"=>["10.24.22.193:8080"], "x-upstream-status"=>["400"], "x-upstream-htime"=>["0.000"], "x-upstream-rtime"=>["1498083367.846"], "x-upstream-ctime"=>["0.000"], "x-tcpinfo"=>["1000, 500, 10, 28960"], "routingkey"=>["SJC11P01"]}> 
令人沮丧的是,RingCentral Ruby SDK的文档中没有用于刷新这些令牌的文档化方法,并且含糊不清地提到了一些关于“手动刷新”的内容。如果您对我的请求或SDK有任何想法,我们将不胜感激。我更愿意执行刷新,而不是一次又一次地重新验证

令人沮丧的是,RingCentral Ruby SDK的文档中没有用于刷新这些令牌的文档化方法,并且含糊不清地提到了一些关于“手动刷新”的内容。如果您对我的请求或SDK有任何想法,我们将不胜感激。我更愿意执行刷新,而不是一次又一次地重新验证

令牌刷新在回购协议的
/docs
文件夹中的详细文档中,也发布在上。我会让那些文件更清楚

文档的“令牌刷新”部分在以下位置可用:

关于调用日志请求,您可以通过下面的API调用直接使用SDK进行调用

client = RingCentralSdk::REST::Client.new do | config |
  # ...
end

client.http.get 'account/~/extension/~/call-log'

对于
accountId
extensionId
路径参数,可以使用
~
指示当前登录用户的帐户和扩展名。如果要指定
accountId
extensionId
,请注意这些是后端id值,与用户拨打的主要公司电话号码或
extensionNumber
不对应。您可以通过调用
account/~/extension
API端点来检索登录用户的
accountId
extensionId

这里有一个指向屏幕截图的链接,但它不起作用
 #<HTTParty::Response:0x7fdf2b0ae800 parsed_response={"errorCode"=>"InvalidParameter", "message"=>"Resource for parameter [accountId] is not found", "errors"=>[{"errorCode"=>"CMN-102", "message"=>"Resource for parameter [accountId] is not found", "parameterName"=>"accountId"}], "parameterName"=>"accountId"}, @response=#<Net::HTTPNotFound 404 Not Found readbody=true>, @headers={"server"=>["nginx/1.10.2"], "date"=>["Wed, 21 Jun 2017 21:39:58 GMT"], "content-type"=>["application/json;charset=UTF-8"], "content-length"=>["290"], "connection"=>["close"], "rcrequestid"=>["2b66c9d6-56ca-11e7-b418-005056bb26b9"], "routingkey"=>["SJC11P01PAS02"], "x-error-id"=>["2b66c9d6-56ca-11e7-b418-005056bb26b9"], "content-language"=>["en-US"], "x-rate-limit-group"=>["heavy"], "x-rate-limit-limit"=>["10"], "x-rate-limit-remaining"=>["9"], "x-rate-limit-window"=>["60"]}>
uri = "https://platform.devtest.ringcentral.com/restapi/oauth/token"
refresh_headers = {"Accept"=>"application/json", "Content-Type"=>"application/x-www-form-urlencoded", 
                   "Authentication"=>"Basic [BASE64_ENCODED_APP_KEY:APP_SECRET_DELIMITED_COMBO]}
refresh_body = {:grant_type=>"refresh_token", :refresh_token=>"#{token_hash[:refresh_token]}"} 
resp = HTTParty.post(uri, headers: refresh_headers, body: URI.www_encode_form(refresh_body))
#<HTTParty::Response:0x7fdf3055d8d8 parsed_response={"error"=>"invalid_client", "error_description"=>"Invalid client: ", "errors"=>[{"errorCode"=>"OAU-153", "message"=>"Invalid client: ", "parameters"=>[{"parameterName"=>"client_id", "parameterValue"=>""}]}]}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @headers={"server"=>["nginx/1.10.2"], "date"=>["Wed, 21 Jun 2017 22:16:07 GMT"], "content-type"=>["application/json;charset=utf-8"], "transfer-encoding"=>["chunked"], "connection"=>["close"], "x-application-context"=>["application:8080"], "content-language"=>["en"], "www-authenticate"=>["Bearer realm=\"RingCentral REST API\", error=\"invalid_client\", error_description=\"Invalid client: \""], "rcrequestid"=>["3958edb2-56cf-11e7-8758-005056bb26b9"], "aceroutingkey"=>["sjc11-c01-ace01.c83d65c2-46d3-11e7-ab8e-005056a73f60"], "x-server-name"=>["sjc06-c01-hlb01"], "x-request-time"=>["0.000"], "x-upstream-server"=>["10.24.22.193:8080"], "x-upstream-status"=>["400"], "x-upstream-htime"=>["0.000"], "x-upstream-rtime"=>["1498083367.846"], "x-upstream-ctime"=>["0.000"], "x-tcpinfo"=>["1000, 500, 10, 28960"], "routingkey"=>["SJC11P01"]}> 
:'-(
client = RingCentralSdk::REST::Client.new do | config |
  # ...
end

client.http.get 'account/~/extension/~/call-log'