Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Uber API:request\u ride with sandbox\u mode=True正在抛出错误消息_Python_Uber Api - Fatal编程技术网

Python Uber API:request\u ride with sandbox\u mode=True正在抛出错误消息

Python Uber API:request\u ride with sandbox\u mode=True正在抛出错误消息,python,uber-api,Python,Uber Api,request\u ridewithsandbox\u mode=True正在抛出错误消息。下面是我的代码和整个错误消息 #Python 3.x from uber_rides.session import Session from uber_rides.client import UberRidesClient session = Session(server_token="something-special") client = UberRidesClient(session,sandbox

request\u ride
with
sandbox\u mode=True
正在抛出错误消息。下面是我的代码和整个错误消息

#Python 3.x
from uber_rides.session import Session
from uber_rides.client import UberRidesClient
session = Session(server_token="something-special")
client = UberRidesClient(session,sandbox_mode=True)
#UberX product id
product_id = '04a497f5-380d-47f2-bf1b-ad4cfdcb51f2' 
response = client.request_ride(product_id, 37.77, -122.41, 37.79, -122.41)
ride_details = response.json
ride_id = ride_details.get('request_id')
response = client.update_sandbox_ride(ride_id, 'accepted')
print(response)

#error message
...
...
uber_rides.errors.ClientError: The request contains bad syntax or   
cannot be filled due to a fault from the client sending the request.

您将获得4XX ClientError,因为您正试图使用服务器令牌请求乘坐。如果您处理错误并检查它,您将看到它是一个
401:Unauthorized error

为了请求乘坐,您需要获得具有
request
范围的OAuth2访问令牌

服务器令牌可以访问产品、时间估计和价格估计等端点。要访问更多受保护的资源,如用户活动或请求端点,您将需要遵循OAuth2

Uber的pythonsdk中也有一个