v1 / requests的优步api身份验证错误{"消息" =>"缺少范围:请求","代码" =>"未授权&#34 ;}

时间:2016-06-13 05:55:49

标签: ruby-on-rails uber-api

我正在使用rails和预订控制器中的uber api我有这样的代码:     需要' ruby​​gems'

require 'httparty'

class BookingsController < ApplicationController
def index
lat = params[:lat].to_s
long = params[:long].to_s
drop_lat = params[:drop_lat].to_s
drop_lng = params[:drop_lng].to_s


ola_body = {
"pickup_lat" => 12.9490936,
"pickup_lng" => 77.6443056,
 "drop_lat" => 12.950279,
"drop_lng" => 77.641938,
"pickup_mode" => "NOW",
"category" => "auto"
 }
ola_headers = {
"Authorization" => "Bearer TOKEN", 
"X-APP-TOKEN" => "TOKEN"
}
uber_body = {

"product_id" => "7e86473c-5f57-4bd8-b465-07b3eec9e633",
"start_latitude" => 37.761492,
"start_longitude" => -122.423941,
"end_latitude"=> 37.775393,
"end_longitude"=> -122.417546

 }
uber_headers = {
'Content-Type' => 'application/json',
 "Authorization" => "Bearer TOKEN"
  }
 @uber_ride_request = HTTParty.post("
 https://api.uber.com/v1/requests",
 :params => uber_body  ,
 :headers => uber_headers ).parsed_response

  @ola_booking = HTTParty.post(
  "http://sandbox-t.olacabs.com/v1/bookings/create ", 
  :body => ola_body,
  :headers => ola_headers
   ).parsed_response

  respond_to do |format|
  format.json { render :json => JSON.parse(@uber_ride_request) }
  format.json { render :json => JSON.parse(@ola_booking) }
  format.html { render "index.html.erb" }

end

end
end

Ola预订请求给出了适当的回复,但在与优步合作时,它给了我一个错误{&#34;消息&#34; =&gt;&#34;缺少范围:请求&#34;,&#34;代码&#34 ; =&gt;&#34;未经授权的&#34;}。可能的原因是什么?

0 个答案:

没有答案