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

Missing cookie SESSONID #20

Closed
lmerhay opened this issue Sep 26, 2023 · 23 comments
Closed

Missing cookie SESSONID #20

lmerhay opened this issue Sep 26, 2023 · 23 comments
Assignees
Labels
bug Something isn't working

Comments

@lmerhay
Copy link

lmerhay commented Sep 26, 2023

Hi, I have been using MiScale Exporter on Android for a while now, without any issues, however recently, whenever I am trying to upload data to Garmin, I get a "Missing cookie SESSIONID" message and the upload fails.
Is this a known issue? Can you pls let me know if you need any more specific info?
Thanks!

@lswiderski
Copy link
Owner

Hi @lmerhay !

Thanks for the report. I have the same error and it looks like Garmin has changed something in the way I log in. I'll look into it today to investigate.

@lmerhay
Copy link
Author

lmerhay commented Sep 26, 2023 via email

@lswiderski lswiderski added the bug Something isn't working label Sep 26, 2023
@lswiderski lswiderski self-assigned this Sep 26, 2023
@lswiderski
Copy link
Owner

Status for today:
It looks like most of the open source 3rd party apps that connect to Garmin stopped working.

My findings:
Any action now require Authorization Bearer JWT Token, new Cookie JWT_FGP=, new Header Di-Backend: connectapi.garmin.com

the JWT Token can be obtained under https://connect.garmin.com/modern/di-oauth/exchange it require 3 Cookies: __cflb=, notice_behavior=implied,eu;, SESSIONID=. In response header I also receive JWT_FGP Cookie

@lswiderski
Copy link
Owner

@SimonBaars
Copy link

SimonBaars commented Sep 27, 2023

I implemented a solution for this problem in related Python repositories:

Since I don't know much about this repo, I don't know what exact auth method is used, but I figure a similar solution could work.

@lswiderski
Copy link
Owner

@SimonBaars Thanks! I will check for sure, although I can't use Garth directly because of the project language (c#) I will reimplement the same flow

@lswiderski
Copy link
Owner

Status update: With library OAuth.DotNetCore I received proper oAuth1 token. I will do more tests during the weekend.

@lswiderski
Copy link
Owner

Progress update:
Login and upload of activity (weight) works already works as external lib. Now it's time to test it in Android.

https://github.com/lswiderski/GarminWeightScaleUploader/blob/master/Libs/garmin-connect-client/GarminConnectClient.Lib/Services/Client.cs

@jesuslg123
Copy link

Progress update: Login and upload of activity (weight) works already works as external lib. Now it's time to test it in Android.

https://github.com/lswiderski/GarminWeightScaleUploader/blob/master/Libs/garmin-connect-client/GarminConnectClient.Lib/Services/Client.cs

Thanks! if you can provide the APK I could give it a try in Android.

@lswiderski
Copy link
Owner

Ok I fixed the App. It works on an emulator and my phone. Package was sent to Google Play Store to check and certificate and should be available to update within 24h.

.AAB and .APK installers are available here https://github.com/lswiderski/mi-scale-exporter/releases/tag/v2.0.8

@jesuslg123 Please check.

Any confirmation or bug report is welcome.

@jesuslg123
Copy link

Progress update: Login and upload of activity (weight) works already works as external lib. Now it's time to test it in Android.
https://github.com/lswiderski/GarminWeightScaleUploader/blob/master/Libs/garmin-connect-client/GarminConnectClient.Lib/Services/Client.cs

Thanks! if you can provide the APK I could give it a try in Android.

I don't have the scale now but I did try to upload the data from previous days and this morning and it is failing with 3 different errors, one after each attempt.

Screenshot_20230930_170023
Screenshot_20230930_170032
Screenshot_20230930_170038

Any idea?

@lswiderski
Copy link
Owner

Thank you. I need to work on more detailed logs. Error about expected pattern means that Garmin somehow did not authenticated you. Do you have MFA/2FA turned off? What version of Android do you use? The weight did not uploaded in background?

@jesuslg123
Copy link

jesuslg123 commented Sep 30, 2023

Thanks for the support. Something interesting happened. I did restart the phone and worked fine this time.

May the Google play version kept running some service when I did remove to install the GitHub version?

Now works uploading manually. Automatically with the scale I can not test right now, sorry

@lswiderski
Copy link
Owner

Thank you. On Scale part nothing changed so should work fine. In near future I will add some retry policy to it because I can see it can don't work randomly.

Anyway I'm happy We won with Garmin and connection is working Again.

@SirYaro
Copy link

SirYaro commented Sep 30, 2023

In my case, I was able to send weight alone. When other values are present, I'm getting the same message as @jesuslg123 on 2nd and 3rd screenshot.

I tried resend like... 20 times. I'm persistent... :P

@SirYaro
Copy link

SirYaro commented Sep 30, 2023

Tbh I don't think this issue is resolved... :(

@lswiderski lswiderski reopened this Sep 30, 2023
@lswiderski
Copy link
Owner

@SirYaro Ohh I will investigate more

@lswiderski
Copy link
Owner

@SirYaro I got the same error when I'm back to opened app. When I closed (kill) and opened again, stand on scale, get measurement and uploaded with success.

@SirYaro
Copy link

SirYaro commented Sep 30, 2023

Yup. 9/10 it works like that. Which is okay-ish...? :)

I also noticed that I'm able to send data only one time. If I hit "send" second, third etc time (with different data and day) I'm getting this:
1696093617804

@lswiderski
Copy link
Owner

For now I must be ok :/ In free time, I will rewrite the Garmin Connect part. But it will take some time. I wanted to release the fix asap even if it's not perfect.

@SimonBaars
Copy link

404 sounds as if it is trying to reach out to a URL unauthenticated. The new method only works for oauth2 authenticated endpoints, not for scraping webpages.
@lswiderski Do you have a list of Garmin URLs that the app tries to access?

@lswiderski
Copy link
Owner

@SimonBaars The problem was with the way of use of the Garmin client. Everytime when upload is done, method is trying to authenticate the user. On the second time, the auth headers was already there and the initial url was returning 404 (https://connect.garmin.com/modern/auth/hostname). Hotfixed it in 2.0.9 by clearing the headers of the http client.

@lswiderski
Copy link
Owner

As I can see on version 2.0.9 I don't have that problems anymore, So I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants