Skip to content
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

Unable to Upload to Garmin #68

Open
20TomTom opened this issue Oct 24, 2023 · 29 comments
Open

Unable to Upload to Garmin #68

20TomTom opened this issue Oct 24, 2023 · 29 comments

Comments

@20TomTom
Copy link

Passwords and everything checked. Garmin has had an update ....

@lolo406
Copy link

lolo406 commented Oct 24, 2023

I have the same problem

@ajayrana1310
Copy link

Same problem.

@talexop
Copy link

talexop commented Oct 25, 2023

same problem.

@Maarty
Copy link

Maarty commented Oct 25, 2023

Garmin recently changed authentication to OAuth, it first did not affect the endpoint for .fit upload, but probably now it does.
Some inspiration on how to make this work can be found in this lib https://github.com/matin/garth/tree/main

@rakatika
Copy link

rakatika commented Nov 3, 2023

Anyone manage to solve this?

@Maarty
Copy link

Maarty commented Nov 6, 2023

I am not a Java developer, but if someone wants to fix this, basically, following the pattern in this lib https://github.com/matin/garth/tree/main you need to do the following steps:

  1. get the correct cookies and "ticket" - already done in app/src/main/java/org/kochka/android/weightlogger/tools/GarminConnect.java
  2. Get OAuth1 token:
  1. Exchange OAuth1 token for OAuth2 token
  1. In step 3 you receive an OAuth2 token, which then can be used in all API requests as a Bearer token in the Authentication header

The OAuth2 token has a classic expiration, and it can be refreshed by a refresh token, or regenerated by exchanging the OAuth1 token again (that one has a 1-year expiration).
Also, in the API url stop using modern/proxy in the path and that will work.

@eniac2000
Copy link

Same problem here

@Selduro
Copy link

Selduro commented Dec 13, 2023

I do have the same Problem. Uploading the generated .fit-File via the linked python client is possible. I do lack the ability to integrate this new process into the app, though. I would really appreciate a solution that's as convenient as the app was before.

@mikelikesspam
Copy link

This app has 50k+ downloads on Google Play. I'd happily pay for an upgraded app that supported 2fa and sync to Garmin. Surely there are enough people willing to buy a cup of coffee to make this worthwhile for a new developer to pickup.

@matin - I don't know you so forgive me plugging you here, but this seems like a trivial fix for you. Your code is already cited above.

@matin
Copy link

matin commented Dec 18, 2023

@kochka I'm pretty terrible at Java, but I'm happy to provide guidance or help in any way. It looks like @Maarty outlined the correct auth flow perfectly. Are you up for making the change or at least reviewing a PR?

@matin
Copy link

matin commented Dec 18, 2023

@matin - I don't know you so forgive me plugging you here, but this seems like a trivial fix for you. Your code is already cited above.

@mikelikesspam no forgiveness required 😄. Always happy to help in any way I can!

@Syntax753
Copy link

Created an initial draft PR for these changes following your excellent insights @matin !
Still WIP and imagine I need to handle the cookies returned after signin..

Any insights would be fantastic - and happy holidays if this goes in to next year :D

#69

@kochka
Copy link
Owner

kochka commented Dec 21, 2023

@matin I'm not a Java developer neither, I did this app back in the day to fit my needs 😅
I'm currently really busy but I'll try to help, and of course, @Syntax753, I will merge and publish a PR.

@Syntax753
Copy link

Syntax753 commented Dec 21, 2023

@kochka ! Good to see you! I wasn't sure how active the repo was but just looking into getting the oAuth requests working and then hopefully submitting a working PR 😄

My background is Java/Maven (4 years ago) but not Android/Gradle - though with your existing work, @matin's OAuth skills, and my typin,g we should get there 👍😄

@kochka
Copy link
Owner

kochka commented Dec 21, 2023

@Syntax753 Good luck with that 😄 If you do not figure out the last bits to make it works, I'll try to find some time during the WE to help.

@jesperuc
Copy link

jesperuc commented Feb 7, 2024

Would it be possible to Add a paid version/ pro version so we can support the development of the app (actually just this one service - upload to Garmin Connect :-) )

looking forward to this will hopefully be fixed one day.

@Syntax753
Copy link

Syntax753 commented Feb 7, 2024 via email

@jesperuc
Copy link

jesperuc commented Feb 7, 2024

That's completely fair - I think we all now that situation now and then :-)

Unfortunately I dont have the knowledge on coding to provide my help.

@Maarty
Copy link

Maarty commented Feb 19, 2024

@Syntax753 if you need any help, I can guide you with the flow, unfortunately, I am not very familiar with Java/Android.
Following the flow I wrote in the comment above should be enough. You need to implement steps 2-4.
For constructing the Oauth1 header you can find any tutorial on how it should look, or you can use a library - For example here https://oauth.net/1/ are a few libraries also for Java.
Basically, the header should look something like this
"OAuth oauth_consumer_key="{consumerKey}",oauth_signature_method="{signatureMethod}",oauth_timestamp="{timestamp}",oauth_nonce="{nonce}",oauth_version="{version}",oauth_signature="{signature}"

You should feed the library with the Oauth1 token, consumer key and consumer secret. And it should return you the whole header. Basically, it calculates the signature, which is some HMAC-SHA1 hash created from the provided input.

@Syntax753
Copy link

Syntax753 commented Feb 19, 2024 via email

@louisjennings
Copy link
Contributor

louisjennings commented Feb 21, 2024

I got the auth flow working a few days ago (and recently added support for MFA) on a branch based on @Syntax753's work.

My most recent commit is able to successfully upload files to Garmin and I am currently running a debug build on my phone. I need to clean up the code and add support for saving and refreshing authentication. Once that is done, I'd be happy to get the changes merged in.

If you don't have MFA (multi factor authentication/two factor authentication) on your account, the current state of the code should be workable. As I haven't yet added support for OAuth2 refresh, if MFA is enabeld, you'll have to enter an MFA code every time you upload (which could be annoying).

I don't plan on releasing APKs on my forked repo unless I'm unable to get the changes merged into this repo. If you want the changes before the PR is merged, you can build from source.

The branch can be found here: https://github.com/louisjennings/WeightLogger/tree/unable-to-upload-to-garmin-%2368

(I'm not a Java/Android developer, so I'd welcome a review from someone with Android development experience)

@Syntax753
Copy link

Syntax753 commented Feb 21, 2024 via email

@Syntax753
Copy link

I've reviewed your changes @louisjennings and they look very good to me!
Can a PR be raised @kochka?

@kochka
Copy link
Owner

kochka commented Feb 21, 2024

@Syntax753 Yes of course !

@Petr-Mi
Copy link

Petr-Mi commented Feb 22, 2024

I don't know if this will help, but there is solution in this repository - https://github.com/lswiderski/mi-scale-exporter

@Petr-Mi
Copy link

Petr-Mi commented Apr 2, 2024

Any news?

@atavius
Copy link

atavius commented Jun 9, 2024

@kochka Are there any updates when new version with this fix will be released?

@kochka
Copy link
Owner

kochka commented Jun 10, 2024

I didn't receive any PR, it was a work in progress.

@atavius
Copy link

atavius commented Sep 19, 2024

Ok I am a bit confused as it seem to me that the fix is available based on comments.
@louisjennings Is your branch working? If so can you create PR for Kochka?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests