pe-st / garmin-connect-export

Download a copy of your Garmin Connect data, including stats and GPX tracks.
MIT License
364 stars 75 forks source link

HTTP 403 Authentication Error #59

Closed RyanAugust closed 3 years ago

RyanAugust commented 3 years ago

Raising the presence of a new round of authentication errors.

Connecting to Garmin Connect... Done.
[ERROR] Failed to reach url https://sso.garmin.com/sso/signin?service=https%3A%2F%2Fconnect.garmin.com%2Flegacy%2Fsession&webhost=https%3A%2F%2Fconnect.garmin.com&source=https%3A%2F%2Fconnect.garmin.com%2Fen-US%2Fsignin&redirectAfterAccountLoginUrl=https%3A%2F%2Fconnect.garmin.com%2Flegacy%2Fsession&redirectAfterAccountCreationUrl=https%3A%2F%2Fconnect.garmin.com%2Flegacy%2Fsession&gauthHost=https%3A%2F%2Fsso.garmin.com%2Fsso&locale=en_US&id=gauth-widget&cssUrl=https%3A%2F%2Fstatic.garmincdn.com%2Fcom.garmin.connect%2Fui%2Fcss%2Fgauth-custom-v1.2-min.css&clientId=GarminConnect&rememberMeShown=true&rememberMeChecked=false&createAccountShown=true&openCreateAccount=false&displayNameShown=false&consumeServiceTicket=false&initialFocus=true&embedWidget=false&generateExtraServiceTicket=true&generateTwoExtraServiceTickets=false&generateNoServiceTicket=false&globalOptInShown=true&globalOptInChecked=false&mobile=false&connectLegalTerms=true&locationPromptShown=true&showPassword=true#, error: HTTP Error 403: Forbidden
Requesting Login ticket...Traceback (most recent call last):
  File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 1063, in <module>
    main(sys.argv)
  File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 865, in main
    login_to_garmin_connect(args)
  File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 516, in login_to_garmin_connect
    login_response = http_req_as_string(URL_GC_LOGIN + '#', post_data, headers)
  File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 273, in http_req_as_string
    return http_req(url, post, headers).decode()
  File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 249, in http_req
    response = OPENER.open(request, data=post)
  File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 532, in open
    response = meth(req, response)
  File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 570, in error
    return self._call_chain(*args)
  File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

Will need to confirm if this call is running into the same cloudflare error that other repos such as garmin-uploader have reported. The workaround currently in place there is to make the calls more cloudflare friendly by replaceing the requests with cloudscraper (see here).

I'll do some tests tonight to confirm the proplem and check the viability of this fix for us as well.

sgowtham commented 3 years ago

Tried it moments ago and I did not encounter such a problem.

On Mon, May 24, 2021 at 9:54 PM Ryan Duecker @.***> wrote:

Raising the presence of a new round of authentication errors.

Connecting to Garmin Connect... Done. [ERROR] Failed to reach url https://sso.garmin.com/sso/signin?service=https%3A%2F%2Fconnect.garmin.com%2Flegacy%2Fsession&webhost=https%3A%2F%2Fconnect.garmin.com&source=https%3A%2F%2Fconnect.garmin.com%2Fen-US%2Fsignin&redirectAfterAccountLoginUrl=https%3A%2F%2Fconnect.garmin.com%2Flegacy%2Fsession&redirectAfterAccountCreationUrl=https%3A%2F%2Fconnect.garmin.com%2Flegacy%2Fsession&gauthHost=https%3A%2F%2Fsso.garmin.com%2Fsso&locale=en_US&id=gauth-widget&cssUrl=https%3A%2F%2Fstatic.garmincdn.com%2Fcom.garmin.connect%2Fui%2Fcss%2Fgauth-custom-v1.2-min.css&clientId=GarminConnect&rememberMeShown=true&rememberMeChecked=false&createAccountShown=true&openCreateAccount=false&displayNameShown=false&consumeServiceTicket=false&initialFocus=true&embedWidget=false&generateExtraServiceTicket=true&generateTwoExtraServiceTickets=false&generateNoServiceTicket=false&globalOptInShown=true&globalOptInChecked=false&mobile=false&connectLegalTerms=true&locationPromptShown=true&showPassword=true#, error: HTTP Error 403: Forbidden Requesting Login ticket...Traceback (most recent call last): File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 1063, in main(sys.argv) File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 865, in main login_to_garmin_connect(args) File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 516, in login_to_garmin_connect login_response = http_req_as_string(URL_GC_LOGIN + '#', post_data, headers) File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 273, in http_req_as_string return http_req(url, post, headers).decode() File "C:\Users\ryand\git\garmin-connect-export\gcexport.py", line 249, in http_req response = OPENER.open(request, data=post) File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 532, in open response = meth(req, response) File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 642, in http_response 'http', request, response, code, msg, hdrs) File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 570, in error return self._call_chain(args) File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 504, in _call_chain result = func(args) File "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden

Will need to confirm if this call is running into the same cloudflare error that other repos such as garmin-uploader https://github.com/La0/garmin-uploader/issues/28 have reported. The workaround currently in place there is to make the calls more cloudflare friendly by replaceing the requests with cloudscraper (see here https://github.com/La0/garmin-uploader/pull/30/commits/8adfbdcd545abe9db4959ae8d8ccc99133593d2d ).

I'll do some tests tonight to confirm the proplem and check the viability of this fix for us as well.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pe-st/garmin-connect-export/issues/59, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXCPKDYEXP52Z24Q4PGKS3TPL7MXANCNFSM45OJFWWA .

--

Gowtham, PhD Director of Research Computing, IT Res. Assoc. Professor, College of Computing Michigan Technological University

(906) 487-4096 https://hpc.mtu.edu

mainzelM commented 3 years ago

I'm experiencing this problem as well for quite some time. However, for me the cloudscraper-based fixes did not work (I've ran into a 403 with https://github.com/jacobhell/garminexport)

moderation commented 3 years ago

I've downloaded rides from Sunday and today (US California time) with my fork at https://github.com/moderation/garmin-connect-export without errors

Ebrohm commented 3 years ago

I had the same problem last week. I switched from Python 3.4 to 3.9. Now it works fine.

pe-st commented 3 years ago

What version of Python do you use, @RyanAugust ? Is it 3.6 as "C:\Users\ryand\miniconda3\envs\gc_36\lib\urllib\request.py" in your stacktrace might suggest?

I have no such problems using Python 3.9

rsjrny commented 3 years ago

I have also tested with Python 3.6, 3.7, and 3.9. Version 3.9 has no issues downloading

mainzelM commented 3 years ago

I'm experiencing this problem as well for quite some time. However, for me the cloudscraper-based fixes did not work (I've ran into a 403 with https://github.com/jacobhell/garminexport)

Yes, it's related to the Python version. Moving from Python 2.7.5 to Python 3.6.8 fixes the problem.

RyanAugust commented 3 years ago

@pe-st Yes, was running in a 3.6.13 environment. Following @rsjrny suggestion, I'm not encountering errors when executing within 3.7 or 3.9 environments.

pe-st commented 3 years ago

As @RyanAugust confirmed, this is not an issue of the script, but of the Python version. It makes no sense to work around HTTP issues of old versions if upgrading to newer 3.x version solves the issue.