magnific0 / nokia-weight-sync

Get weight from Nokia Health and update in Garmin Connect or Smashrun
GNU General Public License v3.0
71 stars 30 forks source link

configparser exception: no nokia section #1

Closed cristian5th closed 6 years ago

cristian5th commented 6 years ago

When executing the first setup with the command: python3 nokia-weight-sync.py -k CONSUMER_KEY -s CONSUMER_SECRET setup nokia

I get an exception from configparser.py stating that there is no "nokia" section.

File "nokia-weight-sync.py", line 170, in <module> client_nokia = auth_nokia( config ) File "nokia-weight-sync.py", line 150, in auth_nokia creds = nokia.NokiaCredentials(config.get('nokia', 'access_token'), config.get('nokia', 'access_token_secret'), File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 781, in get d = self._unify_values(section, vars) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 1141, in _unify_values raise NoSectionError(section) configparser.NoSectionError: No section: 'nokia'

Do you know what am I doing wrong?

Thank you.

magnific0 commented 6 years ago

Hi @cristian5th

thanks for checking out the project and reporting this issue. The error was with the script. It was trying to authenticate with Nokia before setting up the service in the first place. This should now be fixed. Can you try the new version and report back?

cristian5th commented 6 years ago

Hello @magnific0

The nokia section issue is corrected now, but the execution stopped now when performing the authorization with Nokia due to consumer_key missing.

I believe line 73 should call options.key and options.secret instead of options.consumer_key and options.consumer_secret

File "nokia-weight-sync.py", line 179, in <module> setup_nokia( options, config ) File "nokia-weight-sync.py", line 73, in setup_nokia auth = nokia.NokiaAuth(options.consumer_key, options.consumer_secret) AttributeError: 'Values' object has no attribute 'consumer_key'

Thanks for your fast answer, by the way.

cristian5th commented 6 years ago

When doing the change I suggest at line 73, then the authorization works and I can continue the process but I'm getting stuck a little bit further.

I have to go to a webpage in order authorize the app and to get que oauth_verifier which I get correctly. When I type it, then I get a big exception which I cannot fully understand:

Please enter your oauth_verifier: FNTX2i4ldDIhPjGHo50 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_oauthlib/oauth1_session.py", line 355, in _fetch_token token = dict(urldecode(r.text.strip())) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_oauthlib/oauth1_session.py", line 33, in urldecode return json.loads(body) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "nokia-weight-sync.py", line 179, in <module> setup_nokia( options, config ) File "nokia-weight-sync.py", line 77, in setup_nokia creds = auth.get_credentials(oauth_verifier) File "/Users/cralvarez/Python_scripts/nokia-weight-sync-master/nokia.py", line 84, in get_credentials tokens = oauth.fetch_access_token('%s/access_token' % self.URL) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_oauthlib/oauth1_session.py", line 304, in fetch_access_token token = self._fetch_token(url, **request_kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_oauthlib/oauth1_session.py", line 361, in _fetch_token raise ValueError(error) ValueError: Unable to decode token from token response. This is commonly caused by an unsuccessful request where a non urlencoded error message is returned. The decoding error was Expecting value: line 1 column 1 (char 0)

cristian5th commented 6 years ago

Hmmm! I believe I was not typing the right oauth_verifier because it is different with every execution.

Now, I'm not getting any error but I'm getting an unknown command message:

Please enter your oauth_verifier: ydeNw84Xmk39ujsTDY Unknown command Available commands: setup, sync, last, userinfo, subscribe, unsubscribe, list_subscriptions

cristian5th commented 6 years ago

Ok, I found something. Changes I did so I could make the Nokia setup work:

nokia-weight-sync.py

I'm sorry but I don't know how to propose this changes to GitHub. This is a really user unfriendly webpage.

magnific0 commented 6 years ago

Hi, just after I posted my earlier message I fixed some other issues too like the unknown command and consumer_key.

So you can just pull the code (again) to fix these.

magnific0 commented 6 years ago

That would be commits ec2d7785 and 988d9df3. I thought I had made them in time before you had a chance to check it out, but you were too fast ;-).

cristian5th commented 6 years ago

Great! Configuration is working correctly now for Nokia and Garmin.

Just to complete the point: at your README.md file, you state under Usage point 3, that the last measurement group is being displayed during the Nokia configuration process. Well, this is no more true after the lasts changes you made.

Now I'm struggling with syncing but I will open a new point, if needed. Let me keep on testing.

Many thanks.

magnific0 commented 6 years ago

Hi @cristian5th good to hear these problems are fixed. If you run into any new issues or comments, please feel free to open another issue! Thanks for the feedback and testing the app. I will adapt the README later.