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

auth failing #5

Closed
jorgeboucas opened this issue May 23, 2021 · 5 comments
Closed

auth failing #5

jorgeboucas opened this issue May 23, 2021 · 5 comments

Comments

@jorgeboucas
Copy link
Contributor

(venv) laptop:~/garmin-workouts% python -m garminworkouts -u USERNAME -p PASSWORD import --ftp FTP SST.short.xlsx
INFO:garminworkouts.garmin.garminclient:Authenticate user 'USERNAME'
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/jboucas/garmin-workouts/garminworkouts/__main__.py", line 112, in <module>
    main()
  File "/Users/jboucas/garmin-workouts/garminworkouts/__main__.py", line 108, in main
    args.func(args)
  File "/Users/jboucas/garmin-workouts/garminworkouts/__main__.py", line 22, in command_import
    with _garmin_client(args) as connection:
  File "/Users/jboucas/garmin-workouts/garminworkouts/garmin/garminclient.py", line 29, in __enter__
    self._connect()
  File "/Users/jboucas/garmin-workouts/garminworkouts/garmin/garminclient.py", line 103, in _connect
    self._authenticate()
  File "/Users/jboucas/garmin-workouts/garminworkouts/garmin/garminclient.py", line 128, in _authenticate
    auth_response.raise_for_status()
  File "/Users/jboucas/garmin-workouts/venv/lib/python3.8/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://sso.garmin.com/sso/signin?service=https%3A%2F%2Fconnect.garmin.com%2Fmodern
@gilshohet
Copy link

Seems the solution is to use cloudscraper: tcgoetz/GarminDB#120

Replacing import requests with import cloudscraper and requests.Session() with cloudscraper.CloudScraper() solved it for me.

@jorgeboucas
Copy link
Contributor Author

@gilshohet thanks!

That solved the authentication issue.

The API seems to have changed to closed model though, even list does not work:

(venv) laptop:~/garmin-workouts% python -m garminworkouts -u USER -p PASSWORD list                                                 
Connecting
INFO:garminworkouts.garmin.garminclient:User 'USER' already authenticated
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/jboucas/garmin-workouts/garminworkouts/__main__.py", line 112, in <module>
    main()
  File "/Users/jboucas/garmin-workouts/garminworkouts/__main__.py", line 108, in main
    args.func(args)
  File "/Users/jboucas/garmin-workouts/garminworkouts/__main__.py", line 53, in command_list
    for workout in connection.list_workouts():
  File "/Users/jboucas/garmin-workouts/garminworkouts/garmin/garminclient.py", line 45, in list_workouts
    response.raise_for_status()
  File "/Users/jboucas/garmin-workouts/venv/lib/python3.8/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 402 Client Error: Payment Required for url: https://connect.garmin.com/modern/proxy/workout-service/workouts?start=0&limit=100

@gilshohet
Copy link

@jorgeboucas oops, meant to open an issue for this a few weeks ago and forgot about it. Based on this commit from python-garminconnect the solution appears to be to change the base URL. I don't have the bandwidth to properly debug/test right now but this change worked for me:

#   _WORKOUT_SERVICE_URL = "https://connect.garmin.com/modern/proxy/workout-service"
    _WORKOUT_SERVICE_URL = "https://connect.garmin.com/proxy/workout-service"

@jorgeboucas
Copy link
Contributor Author

it's working now. Thanks!

@mkuthan
Copy link
Owner

mkuthan commented May 25, 2021

Nice tricks, thanks!

@mkuthan mkuthan closed this as completed May 25, 2021
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

3 participants