ondrej1024 / carelink-python-client

Experimental Medtronic CareLink Client in Python
GNU Affero General Public License v3.0
39 stars 21 forks source link

carelink_carepartner_api_login.py returns exception #15

Closed greencoder closed 10 months ago

greencoder commented 10 months ago

When I try to run carelink_carepartner_api_login.py, I get this exception:

selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 1

I set the debug flag and this was the output:

$ python carelink_carepartner_api_login.py
performing login...
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): clcloud.minimed.eu:443
send: b'GET /connect/carepartner/v6/discover/android/3.1 HTTP/1.1\r\nHost: clcloud.minimed.eu\r\nUser-Agent: python-requests/2.26.0\r\nAccept-Encoding: gzip, deflate, br\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Fri, 19 Jan 2024 17:38:01 GMT
header: Content-Type: application/json;charset=utf-8
header: Content-Length: 15100
header: Connection: keep-alive
header: x-amzn-RequestId: 6026b565-1e71-44f4-b2ad-859ce02a90a6
header: X-Permitted-Cross-Domain-Policies: none
header: Strict-Transport-Security: max-age=31536000 ; includeSubDomains
header: X-Frame-Options: sameorigin
header: Content-Security-Policy: default-src 'self'
header: X-CUM-SIGNATURE: Vx3q7Lg2JOLnl34MxJEahH5fGQdT82AvneWYy4BmQnpvDfEevFOmYZrisClueO5Yods02oPnMOHpi0ASthUMZCRVmr5kM2HGOWcBor2pb3ODHPIcggbCGlVAHMnUXmhzD180A3V3fJk30nbphvJrVxsZg8HAz9QLmp5RCOjAOYMBLrXcuKN4bB3uPVYw4w1kBMdy7IeNqsE4BJRgBJeQzXoNvDWFMMRW/wvwi+OtAgMVFQ+xbjEhcySl6dLSfKSf0CrKP4zBPL3RXgjw+F8BeBtCSiT8Rf5/912kBaTITACHc546mju1S8hCqptCYy0ddQe2N3qxB93Btb1JMAHH6w==
header: x-amz-apigw-id: RzD7FH5dFiAEb0Q=
header: Cache-Control: no-cache, no-store
header: X-Amzn-Trace-Id: Root=1-65aab379-4a6f6baf77b4ea1833996693;Sampled=0;lineage=593762a0:0
DEBUG:urllib3.connectionpool:https://clcloud.minimed.eu:443 "GET /connect/carepartner/v6/discover/android/3.1 HTTP/1.1" 200 15100
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): carelink.minimed.eu:443
send: b'GET /configs/v1/eu_sso_cp_eu_v5.json HTTP/1.1\r\nHost: carelink.minimed.eu\r\nUser-Agent: python-requests/2.26.0\r\nAccept-Encoding: gzip, deflate, br\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: X-Frame-Options: SAMEORIGIN
header: X-Content-Type-Options: nosniff
header: X-XSS-Protection: 1; mode=block
header: Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
header: Vary: Origin
header: Last-Modified: Thu, 09 Nov 2023 15:21:51 GMT
header: ETag: "23db-609b9c35521c0"
header: Accept-Ranges: bytes
header: Content-Type: application/json
header: Vary: Accept-Encoding
header: Content-Encoding: gzip
header: Cache-Control: no-cache
header: Date: Fri, 19 Jan 2024 17:38:02 GMT
header: Content-Length: 4633
header: Connection: keep-alive
header: Akamai-Cache-Status: Miss from child
DEBUG:urllib3.connectionpool:https://carelink.minimed.eu:443 "GET /configs/v1/eu_sso_cp_eu_v5.json HTTP/1.1" 200 4633
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mdtlogin-ocl.medtronic.com:443
send: b'POST /mmcl/connect/client/initialize HTTP/1.1\r\nHost: mdtlogin-ocl.medtronic.com\r\nUser-Agent: python-requests/2.26.0\r\nAccept-Encoding: gzip, deflate, br\r\nAccept: */*\r\nConnection: keep-alive\r\ndevice-id: NTRkZjdmNDc0YzdjZThmYTVmYjhmZDVhNjk4OWJjMjQzYzc4OWExMzliZTMwZTkwNzNhMGM5MjFkMTI0ZGI2Mg==\r\nContent-Length: 89\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'
send: b'client_id=c19218f2-7157-4c93-8fbe-49636e7f9c74&nonce=90a27efb-14c1-7cd3-b0f4-ed8c68e7a3c4'
reply: 'HTTP/1.1 200 OK\r\n'
header: Pragma: no-cache
header: Cache-Control: no-store
header: Content-Encoding: gzip
header: Content-Type: application/json;charset=UTF-8
header: Content-Length: 124
header: Date: Fri, 19 Jan 2024 17:38:05 GMT
header: Server: Layer7-API-Gateway
DEBUG:urllib3.connectionpool:https://mdtlogin-ocl.medtronic.com:443 "POST /mmcl/connect/client/initialize HTTP/1.1" 200 124
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mdtlogin-ocl.medtronic.com:443
send: b'GET /mmcl/auth/oauth/v2/authorize?client_id=5885137f-8722-4fed-98f9-2f70fb8662cf&response_type=code&display=social_login&scope=profile+openid+roles+country+msso+msso_register+msso_client_register&redirect_uri=com.medtronic.carepartner%3A%2Fsso&code_challenge=rrJFhbnFvXIp-izhA6iBh9qqDQWkWvnkdOaafMnPZ8w&code_challenge_method=S256&state=TTFMMFhFUDdyMlYwMWp1Yk HTTP/1.1\r\nHost: mdtlogin-ocl.medtronic.com\r\nUser-Agent: python-requests/2.26.0\r\nAccept-Encoding: gzip, deflate, br\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n'
reply: 'HTTP/1.1 302 Found\r\n'
header: Content-Security-Policy: frame-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com; default-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com; connect-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com; script-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com 'unsafe-inline'; img-src * data:; style-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://fonts.googleapis.com https://*.com.cn https://*.google.com https://*.gstatic.com 'unsafe-inline'; font-src * data:;
header: X-Content-Type-Options: nosniff
header: X-XSS-Protection: 1
header: Location: https://mdtlogin-ocl.medtronic.com/mmcl/auth/oauth/v2/authorize/login?action=display&sessionID=80f1fca8-a227-43e0-ba2b-679367a649cb&sessionData=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.ew0KICAgICJzZXNzaW9uIjogew0KICAgICAgICAic2Vzc2lvbklEIjoiODBmMWZjYTgtYTIyNy00M2UwLWJhMmItNjc5MzY3YTY0OWNiIiwNCiAgICAgICAgImV4cCI6MTcwNTY4OTQ4MywNCiAgICAgICAgImN1cnJlbnRfdXNlcm5hbWUiOiIiLA0KICAgICAgICAiY3VycmVudF91c2VyX2NvbnNlbnQiOiJub25lIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9yb2xlIjoiIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9hY3IiOiIwIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9hdXRoVGltZSI6IjAiLA0KICAgICAgICAiY3VycmVudF91c2VyX2F0dHJpYnV0ZXMiOiIiLA0KICAgICAgICAic2FsdCI6IiIsDQogICAgICAgICJ0aGlyZF9wYXJ0eV9zc29fdG9rZW4iOiIiLA0KICAgICAgICAidGhpcmRfcGFydHlfc3NvX3Rva2VuX3R5cGUiOiIiDQogICAgfSwNCiAgICAicmVxdWVzdF9jb25zZW50Ijogew0KICAgICAgICAiY2xpZW50X25hbWUiOiJPQ0wrLStDYXJlK1BhcnRuZXIrQXBwKy0rT1VTIiwNCiAgICAgICAgInNjb3BlX3ZlcmlmaWVkIjoicHJvZmlsZStvcGVuaWQrcm9sZXMrY291bnRyeSttc3NvK21zc29fcmVnaXN0ZXIrbXNzb19jbGllbnRfcmVnaXN0ZXIiDQogICAgfSwNCiAgICAicmVxdWVzdF9wYXJhbWV0ZXJzIjogew0KICAgICAgICAiZGlzcGxheSI6InNvY2lhbF9sb2dpbiIsDQogICAgICAgICJwcm9tcHQiOiJsb2dpbitjb25zZW50IiwNCiAgICAgICAgImlkX3Rva2VuX2hpbnQiOiIiLA0KICAgICAgICAibG9naW5faGludCI6IiIsDQogICAgICAgICJhY3JfdmFsdWVzIjoiIiwNCiAgICAgICAgImNsaWVudF9pZCI6IjU4ODUxMzdmLTg3MjItNGZlZC05OGY5LTJmNzBmYjg2NjJjZiIsDQogICAgICAgICJub25jZSI6IiIsDQogICAgICAgICJzY29wZSI6InByb2ZpbGUrb3BlbmlkK3JvbGVzK2NvdW50cnkrbXNzbyttc3NvX3JlZ2lzdGVyK21zc29fY2xpZW50X3JlZ2lzdGVyIiwNCiAgICAgICAgIm1heF9hZ2UiOiAiIg0KICAgIH0NCn0.qSlsVC1eyAr6I68rt4_qOBwq_p9_VJcg4y81SKuKp_w&locale=&countrycode=
header: Content-Encoding: gzip
header: Content-Type: text/plain;charset=UTF-8
header: Content-Length: 20
header: Date: Fri, 19 Jan 2024 17:38:03 GMT
header: Server: Layer7-API-Gateway
DEBUG:urllib3.connectionpool:https://mdtlogin-ocl.medtronic.com:443 "GET /mmcl/auth/oauth/v2/authorize?client_id=5885137f-8722-4fed-98f9-2f70fb8662cf&response_type=code&display=social_login&scope=profile+openid+roles+country+msso+msso_register+msso_client_register&redirect_uri=com.medtronic.carepartner%3A%2Fsso&code_challenge=rrJFhbnFvXIp-izhA6iBh9qqDQWkWvnkdOaafMnPZ8w&code_challenge_method=S256&state=TTFMMFhFUDdyMlYwMWp1Yk HTTP/1.1" 302 20
send: b'GET /mmcl/auth/oauth/v2/authorize/login?action=display&sessionID=80f1fca8-a227-43e0-ba2b-679367a649cb&sessionData=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.ew0KICAgICJzZXNzaW9uIjogew0KICAgICAgICAic2Vzc2lvbklEIjoiODBmMWZjYTgtYTIyNy00M2UwLWJhMmItNjc5MzY3YTY0OWNiIiwNCiAgICAgICAgImV4cCI6MTcwNTY4OTQ4MywNCiAgICAgICAgImN1cnJlbnRfdXNlcm5hbWUiOiIiLA0KICAgICAgICAiY3VycmVudF91c2VyX2NvbnNlbnQiOiJub25lIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9yb2xlIjoiIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9hY3IiOiIwIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9hdXRoVGltZSI6IjAiLA0KICAgICAgICAiY3VycmVudF91c2VyX2F0dHJpYnV0ZXMiOiIiLA0KICAgICAgICAic2FsdCI6IiIsDQogICAgICAgICJ0aGlyZF9wYXJ0eV9zc29fdG9rZW4iOiIiLA0KICAgICAgICAidGhpcmRfcGFydHlfc3NvX3Rva2VuX3R5cGUiOiIiDQogICAgfSwNCiAgICAicmVxdWVzdF9jb25zZW50Ijogew0KICAgICAgICAiY2xpZW50X25hbWUiOiJPQ0wrLStDYXJlK1BhcnRuZXIrQXBwKy0rT1VTIiwNCiAgICAgICAgInNjb3BlX3ZlcmlmaWVkIjoicHJvZmlsZStvcGVuaWQrcm9sZXMrY291bnRyeSttc3NvK21zc29fcmVnaXN0ZXIrbXNzb19jbGllbnRfcmVnaXN0ZXIiDQogICAgfSwNCiAgICAicmVxdWVzdF9wYXJhbWV0ZXJzIjogew0KICAgICAgICAiZGlzcGxheSI6InNvY2lhbF9sb2dpbiIsDQogICAgICAgICJwcm9tcHQiOiJsb2dpbitjb25zZW50IiwNCiAgICAgICAgImlkX3Rva2VuX2hpbnQiOiIiLA0KICAgICAgICAibG9naW5faGludCI6IiIsDQogICAgICAgICJhY3JfdmFsdWVzIjoiIiwNCiAgICAgICAgImNsaWVudF9pZCI6IjU4ODUxMzdmLTg3MjItNGZlZC05OGY5LTJmNzBmYjg2NjJjZiIsDQogICAgICAgICJub25jZSI6IiIsDQogICAgICAgICJzY29wZSI6InByb2ZpbGUrb3BlbmlkK3JvbGVzK2NvdW50cnkrbXNzbyttc3NvX3JlZ2lzdGVyK21zc29fY2xpZW50X3JlZ2lzdGVyIiwNCiAgICAgICAgIm1heF9hZ2UiOiAiIg0KICAgIH0NCn0.qSlsVC1eyAr6I68rt4_qOBwq_p9_VJcg4y81SKuKp_w&locale=&countrycode= HTTP/1.1\r\nHost: mdtlogin-ocl.medtronic.com\r\nUser-Agent: python-requests/2.26.0\r\nAccept-Encoding: gzip, deflate, br\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Security-Policy: frame-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com; default-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com; connect-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com; script-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://*.com.cn https://*.google.com https://*.gstatic.com 'unsafe-inline'; img-src * data:; style-src https://*.medtronic.com https://*.minimed.eu https://*.minimed.eu:5132 https://*.minimed.com https://fonts.googleapis.com https://*.com.cn https://*.google.com https://*.gstatic.com 'unsafe-inline'; font-src * data:;
header: X-Content-Type-Options: nosniff
header: X-XSS-Protection: 1
header: Content-Encoding: gzip
header: Content-Type: application/json;charset=UTF-8
header: Content-Length: 276
header: Date: Fri, 19 Jan 2024 17:38:03 GMT
header: Server: Layer7-API-Gateway
DEBUG:urllib3.connectionpool:https://mdtlogin-ocl.medtronic.com:443 "GET /mmcl/auth/oauth/v2/authorize/login?action=display&sessionID=80f1fca8-a227-43e0-ba2b-679367a649cb&sessionData=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.ew0KICAgICJzZXNzaW9uIjogew0KICAgICAgICAic2Vzc2lvbklEIjoiODBmMWZjYTgtYTIyNy00M2UwLWJhMmItNjc5MzY3YTY0OWNiIiwNCiAgICAgICAgImV4cCI6MTcwNTY4OTQ4MywNCiAgICAgICAgImN1cnJlbnRfdXNlcm5hbWUiOiIiLA0KICAgICAgICAiY3VycmVudF91c2VyX2NvbnNlbnQiOiJub25lIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9yb2xlIjoiIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9hY3IiOiIwIiwNCiAgICAgICAgImN1cnJlbnRfdXNlcl9hdXRoVGltZSI6IjAiLA0KICAgICAgICAiY3VycmVudF91c2VyX2F0dHJpYnV0ZXMiOiIiLA0KICAgICAgICAic2FsdCI6IiIsDQogICAgICAgICJ0aGlyZF9wYXJ0eV9zc29fdG9rZW4iOiIiLA0KICAgICAgICAidGhpcmRfcGFydHlfc3NvX3Rva2VuX3R5cGUiOiIiDQogICAgfSwNCiAgICAicmVxdWVzdF9jb25zZW50Ijogew0KICAgICAgICAiY2xpZW50X25hbWUiOiJPQ0wrLStDYXJlK1BhcnRuZXIrQXBwKy0rT1VTIiwNCiAgICAgICAgInNjb3BlX3ZlcmlmaWVkIjoicHJvZmlsZStvcGVuaWQrcm9sZXMrY291bnRyeSttc3NvK21zc29fcmVnaXN0ZXIrbXNzb19jbGllbnRfcmVnaXN0ZXIiDQogICAgfSwNCiAgICAicmVxdWVzdF9wYXJhbWV0ZXJzIjogew0KICAgICAgICAiZGlzcGxheSI6InNvY2lhbF9sb2dpbiIsDQogICAgICAgICJwcm9tcHQiOiJsb2dpbitjb25zZW50IiwNCiAgICAgICAgImlkX3Rva2VuX2hpbnQiOiIiLA0KICAgICAgICAibG9naW5faGludCI6IiIsDQogICAgICAgICJhY3JfdmFsdWVzIjoiIiwNCiAgICAgICAgImNsaWVudF9pZCI6IjU4ODUxMzdmLTg3MjItNGZlZC05OGY5LTJmNzBmYjg2NjJjZiIsDQogICAgICAgICJub25jZSI6IiIsDQogICAgICAgICJzY29wZSI6InByb2ZpbGUrb3BlbmlkK3JvbGVzK2NvdW50cnkrbXNzbyttc3NvX3JlZ2lzdGVyK21zc29fY2xpZW50X3JlZ2lzdGVyIiwNCiAgICAgICAgIm1heF9hZ2UiOiAiIg0KICAgIH0NCn0.qSlsVC1eyAr6I68rt4_qOBwq_p9_VJcg4y81SKuKp_w&locale=&countrycode= HTTP/1.1" 200 276
captcha url: https://mdtlogin-ocl.medtronic.com:443/mmcl/enterprise/login?sessionID=80f1fca8-a227-43e0-ba2b-679367a649cb
INFO:seleniumwire.storage:Using default request storage
INFO:seleniumwire.backend:Created proxy listening on ::ffff:127.0.0.1:64301
Traceback (most recent call last):
  File "/Users/snewman/Desktop/carelink-python-client/carelink_carepartner_api_login.py", line 275, in <module>
    main()
  File "/Users/snewman/Desktop/carelink-python-client/carelink_carepartner_api_login.py", line 271, in main
    token_data = do_login(endpoint_config)
  File "/Users/snewman/Desktop/carelink-python-client/carelink_carepartner_api_login.py", line 180, in do_login
    captcha_code, captcha_sso_state = do_captcha(captcha_url, sso_config["oauth"]["client"]["client_ids"][0]['redirect_uri'])
  File "/Users/snewman/Desktop/carelink-python-client/carelink_carepartner_api_login.py", line 104, in do_captcha
    driver = webdriver.Firefox()
  File "/Users/snewman/.Envs/sandbox3/lib/python3.9/site-packages/seleniumwire/webdriver.py", line 179, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/snewman/.Envs/sandbox3/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    self.service.start()
  File "/Users/snewman/.Envs/sandbox3/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/Users/snewman/.Envs/sandbox3/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 1
ondrej1024 commented 10 months ago

Actually I don't have any idea what could be causing this. I have tested the script only on Linux. @palmarci do you know what is going wrong here?

greencoder commented 10 months ago

Digging in further - it appears it's something with the webdriver.Firefox() call. I'm going to investigate further and I'll report back here.

greencoder commented 10 months ago

Found the answer here: https://stackoverflow.com/questions/70821737/webdriverexception-message-service-geckodriver-unexpectedly-exited-status-cod

I made sure Selenium was the latest version (4.1.0) and then I upgraded geckodriver to 0.34 and it's working now!