kochka / WeightLogger

WeightLogger Android app
Other
69 stars 23 forks source link

WIP Initial attempt at fetching oAuth1 and oAuth2 tokens #69

Open Syntax753 opened 8 months ago

Syntax753 commented 8 months ago

This is a draft PR and requires further coding

I have added the steps to fetch the v1 and v2 oAuth tokens. However, getting a 400 when attempting to retrieve v1 using the "ticket". I have a feeling this is to do with missing cookies that need to be passed so need to fetch those from the sign-in -> ticket call return entity.

This is based on the great insights by matin and referencing https://github.com/matin/garth/blob/6aeb0faaf0d6b473d8dc161373068d2f5413fdfe/garth/sso.py#L21.

I'm in and out over the Christmas period but will pick this up when I can. The foundational logic flow has been typed up at least :)

matin commented 8 months ago

I recommend looking at this successful login session as a reference. The last two requests show the OAuth1 requests.

louisjennings commented 6 months ago

I have built upon the changes in this PR.

My changes can be found on the following branch: https://github.com/louisjennings/WeightLogger/tree/unable-to-upload-to-garmin-%2368

Thanks to @matin for the clear code in garth.

With commit 6c5cdb92ab3b6c9952fa88c78b4bb7fce8f96ff2, I am successfully able to upload data to Garmin (but only if MFA is disabled for the account). In my mind, the next steps (either for this PR or a separate PR) will be:

  1. Add support for MFA (this will require a user input)
  2. Add support for saving and renewing OAuth2 tokens (this will prevent MFA users from having to enter a code for every upload and may generally speed up the upload process slightly)

I had to remove the redirection logic that was present after the ticket is obtained. For some reason this invalidated the ticket. I don't know if this is unneeded legacy code or whether it covers a case that my configuration doesn't replicate. As I didn't see similar logic in the garth login flow, I dropped it.