matin / garth

Garmin SSO auth + Connect Python client
MIT License
294 stars 21 forks source link

Issue connecting to API #43

Closed jnolan95 closed 9 months ago

jnolan95 commented 9 months ago

Been mulling over this issue looking for a workaround for like 2 weeks now. Tried fresh install and multiple devices. I'm very new to programming so the issue could be painfully obvious.

Followed directions in the README and got up to the point of Connect API, at which point I input the sleep API request and get hit with an AssertionError.

Occurs on garth/http.py at line 127 with "assert self.oauth1_token".

Storing my login info and password seems to have worked. The oauth1 & ouath2 tokens also seem to be created.

I believe the tokens have been created because after inputting my username and password, a .garth folder is created in my user directory, and the JSON files pertaining to the tokens reside in there. Maybe that has something to do with it?

Screenshot 2024-01-11 at 2 47 26 AM
matin commented 9 months ago

Hi @jnolan95, you're almost there.

If you've already stored your tokens, you have to make sure you resume/load your tokens with the following:

garth.resume("~/.garth")

Replace "~/.garth" with the location of the directory where you stored your tokens.

Let me know if that works for you.

jnolan95 commented 9 months ago

Ahh your code was correct in the .save and .resume functionality and where it was saved to as .garth. I was trying to figure it out myself which led me down the token path but turns out that wasn't the issue.

As I said, I'm new to programming and saw your README and implemented the "attempt to resume session" code created in one python file and attempted to connect to the API and make calls in another file.

You actually pointed me in the right direction with the resume/load reference. I see now resume has to be called in the same instance as an API call which makes a lot of sense.

Thanks for the help and I love what you did with this code and I'm looking forward to using it

matin commented 9 months ago

Happy to help! Let me know if you have any other questions.