【发布时间】:2018-03-26 17:37:54
【问题描述】:
我是一名优步司机,我正在开发一个 Python 代码来使用 API 优步检索司机历史记录。我已经看过文档,并且我已经编写了第一个代码来进行第一步身份验证:
from uber_rides.auth import AuthorizationCodeGrant
auth_flow = AuthorizationCodeGrant(
'my_client_id',
'partner.trips',
'my_secret_client',
'http://localhost:8000'
)
auth_url = auth_flow.get_authorization_url().replace('+','')
print(auth_url)
作为范围,我设置了 partner.trips,该文档说如果您使用此端点来检索旅行:
https://api.uber.com/v1/partners/trips
当我运行代码时,这是 url 结果:
https://login.uber.com/oauth/v2/authorize?scope=partner.trips&state=a22YiIePVScRMh12gLbgZFnDK6415HHG&redirect_uri=http%3A%2F%2Flocalhost%3A8000&response_type=code&client_id=my_client_id
但是当我将网址放入浏览器时,我收到此错误:
http://localhost:8000/?error=invalid_scope&state=iyzAM1rPWnZDFHqJlXEViTUL3UsLIz2O#_
错误无效范围。我已经查看了我的开发人员仪表板,我没有这个范围,但我有范围历史。因此,如果将历史记录设置为范围,我会将代码接收到重定向 url,但如果我使用此代码生成令牌并使用令牌调用此端点:
https://api.uber.com/v1/partners/trips
我收到此错误:
{"message":"This endpoint requires at least one of the following scopes: partner.trips, partner.admin_trips.locations, partner.admin_trips","code":"unauthorized"}
请帮忙???我快疯了。
【问题讨论】: