【问题标题】:Uber API invalid scope error using python使用 python 的 Uber API 无效范围错误
【发布时间】: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"}

请帮忙???我快疯了。

【问题讨论】:

    标签: python uber-api


    【解决方案1】:

    听起来您没有 partner.trips 范围:
    “我已经查看了我的开发人员仪表板,但我没有这个范围。”

    由于您没有此范围,因此您收到的错误消息是正确的:

    {"message":"此端点至少需要以下范围之一:partner.trips、partner.admin_trips.locations、partner.admin_trips","code":"unauthorized"}

    输入历史范围不会让您访问驱动程序 API partner.trips 范围。您可以通过https://developer.uber.com/products/drivers申请Driver API访问(目前受限)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-03
      • 2015-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多