-
Notifications
You must be signed in to change notification settings - Fork 35
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
Using Refresh Token to Retrieve New Authentication Token #46
Comments
Same here, very useful package (thank you!), but am hitting the same roadblock as RyanJPlant: after initial authentication, the session (obviously) times out. I'd like to extract more data from the same account periodically, so to extract a refresh token & be able to generate a new authentication token would be great. Any ideas? |
A different R package for accessing the FitBit API has a Thanks! |
Thanks @andrewheiss! I had sort of parked this issue for a while but will need to come back to it soon. Looks like the "other" package you suggest is also called fitbitr and has been updated more recently, but still under development? If you don't mind, do let me know if & when you solve somehow? I'll do the same... ;-) |
@MarloesEeftens I figured out the reason it's broken (🎉), but haven't figured out how to fix it. According to the FitBit API documentation (https://dev.fitbit.com/build/reference/web-api/oauth2/#authorization-header), the API authorization request has to include a header named "Authorization" with the key and secret encoded with base64 and prefixed with "Basic: " Getting a token with httr initially seems to work automatically, but it seems that httr's
The tricky part is that both of those base64-enabled workarounds are adapted from older httr code (the other other fitbitr's The best solution is probably to do something like Charlotte did and replace the R6 object so that it'll automatically refresh as needed, but that seems tricky. I've also been scouring the httr documentation to see if there's some built-in way to adjust the POST headers without needing to recreate functions, but so far haven't found a way. |
I'm able to use
token <- fitbitr::oauth_token()
to generate the initial authentication and refresh tokens following browser authentication, however, once the authentication token expires, I can't seem to use the refresh token to generate a new authentication token.Running
token$token$refresh()
gives me the following error:Is this feature implemented already, or does the token refresh need to be managed directly by writing the httr code to handle the process? If it isn't, I would say this would be quite an essential update to this wonderful r package.
The text was updated successfully, but these errors were encountered: