Pythe1337N / garmin-connect

Makes it simple to interface with Garmin Connect to get or set any data point.
MIT License
144 stars 58 forks source link

Garmin Signin API changed #17

Closed mauimauer closed 3 years ago

mauimauer commented 3 years ago

Seems the current version can not login into Connect anymore. Getting HTML responses for all API methods now.

Sign-in POST for Website login now looks like this: https://sso.garmin.com/sso/signin?service=https%3A%2F%2Fconnect.garmin.com%2Fmodern%2F&webhost=https%3A%2F%2Fconnect.garmin.com%2Fmodern%2F&source=https%3A%2F%2Fconnect.garmin.com%2Fsignin%2F&redirectAfterAccountLoginUrl=https%3A%2F%2Fconnect.garmin.com%2Fmodern%2F&redirectAfterAccountCreationUrl=https%3A%2F%2Fconnect.garmin.com%2Fmodern%2F&gauthHost=https%3A%2F%2Fsso.garmin.com%2Fsso&locale=en_US&id=gauth-widget&cssUrl=https%3A%2F%2Fconnect.garmin.com%2Fgauth-custom-v1.2-min.css&privacyStatementUrl=https%3A%2F%2Fwww.garmin.com%2Fen-US%2Fprivacy%2Fconnect%2F&clientId=GarminConnect&rememberMeShown=true&rememberMeChecked=false&createAccountShown=true&openCreateAccount=false&displayNameShown=false&consumeServiceTicket=false&initialFocus=true&embedWidget=false&generateExtraServiceTicket=true&generateTwoExtraServiceTickets=true&generateNoServiceTicket=false&globalOptInShown=true&globalOptInChecked=false&mobile=false&connectLegalTerms=true&showTermsOfUse=false&showPrivacyPolicy=false&showConnectLegalAge=false&locationPromptShown=true&showPassword=true&useCustomHeader=false&mfaRequired=false&performMFACheck=false&rememberMyBrowserShown=false&rememberMyBrowserChecked=false

Pythe1337N commented 3 years ago

Thanks for noticing! I'll look into it asap. Edit: It seems that they've added _csrf and remove some stuff from their singin request.

Abasz commented 3 years ago

I had similar problem with my code. Actually it is the cloudflare protection that kicks in. I got it working using cloudscraper library to make the request. Here is a similar py libarary where this is duscussed.

cyberjunky/python-garminconnect#46

Basically you have to swap the request library to cloudscraper

Also need to pass the csrf token to the post request.

EDIT:

You do not need the actual csrf token to login, just an initial get request.

JensSam commented 3 years ago

Thanks for noticing! I'll look into it asap. Edit: It seems that they've added _csrf and remove some stuff from their singin request.

Hi! Did you manage to fix this? I tried using your library today but it looks like it's not working.

Regards Jens

brentk7 commented 3 years ago

Hi, I tried to use this library but was also unable to connect successfully. Any chance of a fix? Maybe the info here might help?

Thanks

Pythe1337N commented 3 years ago

Good news, everyone! The package is now updated with cloudscraper as @Abasz suggested. There might be some small issues remaining, but those will be handled in separate issues.