cyberjunky / python-garminconnect

Python 3 API wrapper for Garmin Connect to get activity statistics
MIT License
802 stars 132 forks source link

New error no user preferences #160

Closed robquail closed 9 months ago

robquail commented 9 months ago

After months of working fine, I'm suddenly getting this error. Is there some recent change in garminconnect or the Garmin site to explain this?

  File "c:\Users\Rob\Documents\runs\app\garmin.py", line 36, in update_db
    garmin.login()
  File "C:\Users\Rob\AppData\Local\Programs\Python\Python310\lib\site-packages\garminconnect\__init__.py", line 243, in login
    return self.authenticate()
  File "C:\Users\Rob\AppData\Local\Programs\Python\Python310\lib\site-packages\garminconnect\__init__.py", line 383, in authenticate
    self.display_name = user_prefs["displayName"]
TypeError: 'NoneType' object is not subscriptable

login() determines self.session_data is None and calls self.authenticate()

response = self.modern_rest_client.get("", params=params) returns:

<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="ie=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/><style data-href="/styles.a8465107f99a824f09fa.css" id="gatsby-global-css">body,html{height:auto;font:400 14px/22px Open Sans,Helvetica Neue,Helvetica,Arial,sans-serif;color:#222;background-color:#efefef;margin:0}a,a:active,a:hover,a:visited{text-decoration:none;color:inherit}#truste-consent-track{display:block}#truste-consent-content{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;width:100%;box-sizing:border-box}#truste-consent-text{margin:0 1rem 0 0;color:#fff;font-size:16px;font-weight:700;font-family:arial}#truste-consent-buttons>a{color:#fff;font-size:14px;margin:12px 10px 10px;text-align:center;text-decoration:underline}#truste-consent-buttons{display:flex;flex-direction:row;margin-top:1px!important;margin-left:10px!important}#truste-consent-buttons #truste-consent-button,#truste-consent-buttons #truste-consent-required,#truste-consent-buttons #truste-show-consent{font-family:Open Sans,HelveticaNeue,HelveticaNeueu,Arial,sans-serif;font-size:14px;color:#fff;background-color:#4a4a4a;cursor:pointer;padding:5px 20px;margin:12px 0;border-radius:4px;border:none}#truste-consent-buttons #truste-consent-required{margin-left:.5rem}#truste-consent-buttons #truste-show-consent{margin-left:1rem}#truste-consent-buttons #truste-consent-button:hover,#truste-consent-buttons #truste-consent-required:hover,#truste-consent-buttons #truste-show-consent:hover{background-color:#242424;border:none}#truste-cookie-button{color:#fff;margin:1rem;line-height:2}@media (max-width:1024px){#truste-consent-content{flex-direction:column;flex-wrap:nowrap}#truste-consent-text{margin:20px 20px 10px;text-align:center;width:unset!important}#truste-consent-buttons{display:block;text-align:center}#truste-consent-buttons #truste-consent-button,#truste-consent-buttons #truste-consent-required,#truste-consent-buttons #truste-show-consent{padding-top:10px;padding-bottom:10px;width:100%;margin:5px 0}#truste-cookie-button{display:inline-block;margin:auto;padding:15px}#truste-consent-buttons #truste-show-consent{margin-left:0}}.truste_overlay{background:#fff!important;opacity:.8!important}.truste_box_overlay{background:none!important}.truste_box_overlay_inner{border:3px solid #e8e8e8}</style><meta 
name="generator" content="Gatsby 2.32.13"/><title data-react-helmet="true"></title><style type="text/css" id="server-side-jss"></style><link as="script" rel="preload" href="/webpack-runtime-5df688dd07b59ccf541d.js"/><link as="script" rel="preload" href="/framework-f3ec01444cccc4b4057e.js"/><link as="script" rel="preload" href="/styles-2ed6c2e7b748a8320e46.js"/><link as="script" rel="preload" href="/app-949317601b74f8af13e9.js"/><link as="script" rel="preload" href="/eaeed06d504ae546165ee91c3dc1e07947955f13-6dcd5ab7da14191eae89.js"/><link as="script" rel="preload" href="/component---src-pages-signin-js-be26445497aefe4010f7.js"/><link as="fetch" rel="preload" href="/page-data/signin/page-data.json" crossorigin="anonymous"/><link as="fetch" rel="preload" href="/page-data/app-data.json" crossorigin="anonymous"/></head><body><div id="___gatsby"><div style="outline:none" tabindex="-1" id="gatsby-focus-wrapper"><noscript>To sign in to your Garmin account, please enable JavaScript in your web browser.</noscript></div><div id="gatsby-announcer" style="position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0" aria-live="assertive" aria-atomic="true"></div></div><script id="gatsby-script-loader">/*<![CDATA[*/window.pagePath="/signin/";/*]]>*/</script><script id="gatsby-chunk-mapping">/*<![CDATA[*/window.___chunkMapping={"polyfill":["/polyfill-9a6e2095c8f8c9aa1c78.js"],"app":["/app-949317601b74f8af13e9.js"],"component---src-pages-404-js":["/component---src-pages-404-js-774b69b42bb6abedb791.js"],"component---src-pages-account-sharing-js":["/component---src-pages-account-sharing-js-989eff6a0cc060a09afd.js"],"component---src-pages-create-account-js":["/component---src-pages-create-account-js-4a3549073a62d1464afe.js"],"component---src-pages-features-coach-js":["/component---src-pages-features-coach-js-cc27610b5ed82a3c4964.js"],"component---src-pages-features-index-js":["/component---src-pages-features-index-js-990a38d4b41e39285884.js"],"component---src-pages-features-menstrual-cycle-tracking-js":["/component---src-pages-features-menstrual-cycle-tracking-js-559f8ad65d646723b16f.js"],"component---src-pages-features-pregnancy-tracking-js":["/component---src-pages-features-pregnancy-tracking-js-557d66d0c2f96b70fda1.js"],"component---src-pages-index-js":["/component---src-pages-index-js-848563019fe90b815f1a.js"],"component---src-pages-invite-signin-js":["/component---src-pages-invite-signin-js-b683c003279536f6c2be.js"],"component---src-pages-signin-js":["/component---src-pages-signin-js-be26445497aefe4010f7.js"],"component---src-pages-start-index-js":["/component---src-pages-start-index-js-80a59e95a5e3b3c9b120.js"],"component---src-pages-start-index-scale-express-js":["/component---src-pages-start-index-scale-express-js-8480cb34c912ccb8a240.js"],"component---src-pages-start-index-scale-help-js":["/component---src-pages-start-index-scale-help-js-8b4d550ac7dbb4fe81d6.js"],"component---src-pages-start-index-scale-index-js":["/component---src-pages-start-index-scale-index-js-899da91c4ee27b0d298b.js"],"component---src-pages-start-index-scale-mobile-js":["/component---src-pages-start-index-scale-mobile-js-19844f0f9bc606348cb5.js"],"component---src-pages-start-index-scale-wps-js":["/component---src-pages-start-index-scale-wps-js-e6fa9806d7cd2ed613b6.js"],"component---src-pages-start-quickdraw-js":["/component---src-pages-start-quickdraw-js-795e397fac9634ea9033.js"],"component---src-pages-start-quickdraw-legal-js":["/component---src-pages-start-quickdraw-legal-js-fc8979099ccef79743b7.js"],"component---src-pages-start-vivoki-js":["/component---src-pages-start-vivoki-js-59f6275b34ef4ebd0e8f.js"],"component---src-pages-status-js":["/component---src-pages-status-js-bb6902bb697c82eb40c7.js"],"component---src-pages-support-js":["/component---src-pages-support-js-9d76cacf82839fffeb1b.js"]};/*]]>*/</script><script src="/polyfill-9a6e2095c8f8c9aa1c78.js" nomodule=""></script><script src="/component---src-pages-signin-js-be26445497aefe4010f7.js" async=""></script><script src="/eaeed06d504ae546165ee91c3dc1e07947955f13-6dcd5ab7da14191eae89.js" async=""></script><script src="/app-949317601b74f8af13e9.js" async=""></script><script src="/styles-2ed6c2e7b748a8320e46.js" async=""></script><script src="/framework-f3ec01444cccc4b4057e.js" async=""></script><script src="/webpack-runtime-5df688dd07b59ccf541d.js" async=""></script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v8b253dfea2ab4077af8c6f58422dfbfd1689876627854" integrity="sha512-bjgnUKX4azu3dLTVtie9u6TKqgx29RBwfj3QXYt5EKfWM/9hPSAI/4qcV5NACjwAo8UtTeWefx6Zq5PHcMm7Tg==" data-cf-beacon='{"rayId":"80e8ecbecffc7ec5","version":"2023.8.0","b":1,"token":"1bd18b8f69214e379ef7bd34509191ae","si":100}' crossorigin="anonymous"></script>
</body></html>

user_prefs = self.__get_json(response.text, "VIEWER_USERPREFERENCES") returns null

self.display_name = user_prefs["displayName"] errors on object not subscriptable:

pzelnip commented 9 months ago

Getting the same error myself. First noticed today.

matin commented 9 months ago

What version of garminconnect are you using?

robquail commented 9 months ago

oh.. 0.1.48
do I need to update?

matin commented 9 months ago

Yes, please update. garminconnect migrated from Cloudscraper to Garth in #144 to improve auth

holstt commented 9 months ago

Got the same error in a project using 0.1.55, but upgrading to the latest version (0.2.7) fixed the issue.

robquail commented 9 months ago

upgrade fixed it, thanks

cyberjunky commented 9 months ago

Nice to hear all is fixed by the work of matin!