-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getting flask-dance to auto refresh my expired tokens #391
Comments
testing out with my minimal flask-dance-fitbit application: https://github.com/lila/flask-dance-fitbit added a route /fitbitexpiretoken that does the following:
When i hit this url, i now get:
i manually expire the token then issue a get-profile api command. after that the token has been updated with a new refresh token and new expiration. soo... the upshot is: flask-dance is doing the token refresh automatically. How exactly does that happen? it feels a bit like magic to me, as i need a very specific authorization header when refreshing the token. i find it difficult to see how flask-dance or requests-oauth2lib figures that out. Any explanation would be helpful. Thanks in advance :-)
|
if i turn the debugging on for requests_oauthlib using:
then i see the following debug statements:
so it is definitely doing the token refresh. apparently the fitbit refresh api is more standard than i thought... for the record, requests_oauthlib then uses requests.auth to build the authorization headers, then uses refresh_token() to make the call and update the tokens. this all happens behind the scenes of flask-dance. All is good in the world of flask-dance. you can close the issue, but i thought i'd add all this here for completeness (and for when i forget).. cheers and thanks for developing and maintaining flask-dance...
|
Hi,
I'm using the fitbit flask-dance contributed module. All is good, but when my token expires, then i would like to configure flask-dance and requests-oauthlib to automatically refresh the token if expired.
To do that with fitbit oauth, i use the same token url, but need to supply it with different body:
The authorization header is "Basic " + base64 encoded "client_id:client_secret". the body has grant_type and includes the refresh token.
I see that requests_oauthlib does have the mechanism to automatically refresh the token, see https://github.com/requests/requests-oauthlib/blob/master/requests_oauthlib/oauth2_session.py#L405 for example.
and it does check for expired tokens.
my question is: how can i configure the flask-dance fitbit module so that it does the right thing. All i see are two parameters,
fitbit_bp.auto_refresh_url
andfitbit_bp.auto_refresh_kwargs
(see https://github.com/singingwolfboy/flask-dance/blob/main/flask_dance/contrib/fitbit.py )i set
fitbit_bp.auto_refresh_url
to the current url for refreshing the tokens, and i tried settingfitbit_bp.auto_refresh_kwargs
in a few different ways, but i'm just not getting a valid response.any help is greatly appreciated. thanks in advance...
k
The text was updated successfully, but these errors were encountered: