Search code examples
pythonuber-api

Uber API invalid scope error using python


i'm a Uber Driver and i'm developing a python code to retrive the driver history with API Uber. I have seen the documentation and i have write this first code to first step auth:

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)

as scope i have set partner.trips that doc say if you use this endpoint to retrive trips:

https://api.uber.com/v1/partners/trips

when i run the code this is the url result:

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

but when i put the url into browser i recive this error:

http://localhost:8000/?error=invalid_scope&state=iyzAM1rPWnZDFHqJlXEViTUL3UsLIz2O#_

error invalid scope. I have seen into my developer dashbord and i don't have this scope, but i have scope history. So if set history as scope i receive the code into redirect url but if i use this code to generate a token and use the token call this end point:

https://api.uber.com/v1/partners/trips

i recive this error:

{"message":"This endpoint requires at least one of the following scopes: partner.trips, partner.admin_trips.locations, partner.admin_trips","code":"unauthorized"}

any help please??? i'm becoming creazy.


Solution

  • It sounds like you do not have the partner.trips scope:
    "I have seen into my developer dashboard and i don't have this scope."

    As you do not have this scope and thus the error message you are receiving is correct:

    {"message":"This endpoint requires at least one of the following scopes: partner.trips, partner.admin_trips.locations, partner.admin_trips","code":"unauthorized"}

    Entering the history scope does not get you access to the driver API partner.trips scope. You can apply for Driver API access (currently limited) via https://developer.uber.com/products/drivers.