2017-08-28 2 views
0

Uber用のスクリプトを作成しましたが、アクセストークンが期限切れになるまでうまくいきました。 だからここ(ユーバーSDK https://github.com/uber/rides-python-sdkとほぼ同様)コードのこの作品だ:私はさらに何もすることができません有効期限が切れたトークンでPython Uber SDKは、リフレッシュトークンに基づいて30日後にアクセストークンを更新しません。

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) 

が、それはまた

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

返し、私は混乱しています「UberRidesClientを使用してAPIリクエストを作成すると、SDKはトークンの更新を自動的に処理します。

リフレッシュトークンを使用して新しいアクセストークンを取得するにはどうすればよいですか?私は再び承認することができ、それは動作しますが、迷惑です。

答えて

0

有効な更新トークンを持っている場合は、トークンエンドポイント:https://login.uber.com/oauth/v2/tokenを使用して新しいアクセストークンを取得できます。詳細については、Uber documentationを参照してください。

"ユーザーのaccess_tokenが期限切れになった場合、トークンエンドポイントを使用してaccess_tokenに関連付けられているrefresh_tokenを交換することによって、新しいaccess_tokenを取得します。

+0

これはうまくいきます。しかし、SDKに何か問題がありますか?私は本当にそれがどのようにリフレッシュ "自動"を処理するのかわかりません。 –

+0

あなたは次のテストからその方法を知ることができます:https://github.com/uber/rides-python-sdk/blob/master/tests /test_auth.py –

関連する問題