0
votes

I've created a script for Uber and it worked fine until my access token expired. So here's this piece of code (almost similar to Uber SDK https://github.com/uber/rides-python-sdk):

    session = Session(oauth2credential=OAuth2Credential(
        client_id=credential_dict.get('client_id'),
        access_token=credential_dict.get('access_token'),
        expires_in_seconds=credential_dict.get('expires_in_seconds'),
        scopes=credential_dict.get('scopes'),
        grant_type=credential_dict.get('grant_type'),
        redirect_url=credential_dict.get('redirect_url'),
        client_secret=credential_dict.get('client_secret'),
        refresh_token=credential_dict.get('refresh_token')))
    client = UberRidesClient(session)

With the expired token I can not do anything further, it returns

uber_rides.errors.ClientError: 401: No authentication provided.

Also, I'm confused by "The SDK will handle the token refresh for you automatically when it makes API requests with an UberRidesClient."

How can I get my new access token using refresh token? I can authorize again and it works but is annoying.

1

1 Answers

0
votes

You can get new access token if you have valid refresh token by using the token endpoint: https://login.uber.com/oauth/v2/token. For more information check the Uber documentation.

"When the user’s access_token has expired, obtain a new access_token by exchanging the refresh_token that is associated with the access_token using the Token endpoint".