-
Notifications
You must be signed in to change notification settings - Fork 30
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
UPDATED Nokia Health Mate API to OAuth 2.0. Reconfiguration required! #5
Comments
@jschram thanks for opening the issue. I have spent the day updating nokia.py to OAuth 2.0. It seems to work great for me. Updating
I'll leave this issue open for visibility and users to add their findings to. |
I have deleted the nokia section in my previous working config file. I wonder if I now misunderstand what I should type in the callback url?
|
Hi @ltgustavsen you should input the url you were redirected to after you authorized the application. It is your callback url with some additional parameters: I have just made some clarifications to the setup section for Nokia to make this a bit clearer. |
thumbs up |
Well it worked fine yesterday.
The I tried now a few hours later:
|
Hmm I'll have a look at it later why you got the 401. The last message is a result of the access and refresh tokens both expired. The new refresh token wasn't saved because of the error you saw earlier. The only solution is to re setup Nokia. You don't need to remove the section this time. |
Thanks for the change! |
Same thing here; token is expired. It doesn't seem to request a new access token with the request token. According to the Nokia docs, the access_token expires after 4 hours, after which you'll need to request a new token with the refresh_token: Check this part of the docs It seems that there's either no new access token requested before making a new request, or that the newly obtained token isn't used and/or stored. Also, the config never seems to update with a new token or token_expire. |
@ltgustavsen @jschram thanks a lot for your reports. I'll look into it on a very short basis. |
@ltgustavsen @jschram I have just pushed a new update. The problem was that the config was never updated with the new tokens after refresh. This only happened during "sync" mode. "last" mode was working fine, which I used to test on... Hopefully this fixes everything. Please let me know! |
Awesome; I've updated it, completed the setup and did a successful sync. Will check again tomorrow morning (when it has a new measurement from my scale) if it'll hold up. |
For me the access token was expired again today :-( Should the refresh token be updated in the config.ini file each time I run sync?
I also had the "Error code 401" on time today. |
@ltgustavsen thanks for reporting back. If you got the error 401 again I can understand the refresh also failed. I hadn't started investigating 401 yet, but if the program throws an exception it will most definitely exit without updating the configuration file. Catching such exceptions and still handling saving the configuration file is on my to do list. I had just hoped that the 401 happened rarely. But at least for you it doesn't. By the way the config file contents should only be updated if the token has expired. So your findings are normal. You can try this to force an update
It should try to refresh the token just on the basis of it having passed expiration date. Moreover if you edit nokia-weight-sync.py and add
somewhere near the top (say right after |
Here is my log for two runs. One just before and one after the token experes:
|
@magnific0 I'm seeing the same "Exception: Error code 401" error associated with an expired token. |
@fernat @ltgustavsen thanks. I have been looking into this and it is clear to me what is going on: it is still attempting to make the original request with the old token, despite having refreshed correctly. I'm writing a fix now, but I want to be extra careful with testing this time, so I'll probably update tomorrow and post here. |
@fernat @ltgustavsen the last commit should finally fix the issue. I have tested refreshing several times by letting it naturally expire and had no further issue. Hoping it works for you too! |
I'm sorry to report that the issue wasn't fixed. It now seems to stall until a timeout occurs. This also happens when I try to setup the nokia app again:
It stalls here for about 30 seconds, then fails:
|
@magnific0 Alright, no problem; I'll monitor that issue instead. |
Be aware I made some changes to the setup flow. @ltgustavsen I saw you're using a raspberrypi, so be careful choosing your callback url if you choose the new automated flow.
|
@magnific0 - things are working for me, thanks for the update and timely response. |
Yes! Working here as well: |
Great! I'm leaving this issue open for a while so people having to migrate see it, at least until the end of the year (OAuth 1.0 closes November 31). Thanks everyone for your patience and reporting these issues. I'm happy to tell you that directly thanks to the efforts here the upstream library python-nokia got updated to OAuth 2.0 as well. Let's hope it stays quiet for a while now :). |
Nokia sent out a mailing that they'll remove support for oAuth 1.0 as of November 30th, 2018.
https://developer.health.nokia.com/oauth2/#tag/OAuth-1.0-(deprecated)
Would it be possible to change the authentication part of the sync to support oAuth 2.0, so the sync will continue to function after that date?
The text was updated successfully, but these errors were encountered: