personalcapital: PC API login/auth errors starting 11/17/2021

Starting ~2d ago (17-NOV), started getting these Personal Capital API login/auth errors…

% ./wx.ad.py ro Traceback (most recent call last): File "./wx.ad.py", line 60, in <module> pc.login( pc_cred_user , pc_cred_pass ) ; File "/usr/local/lib/python3.4/site-packages/personalcapital/personalcapital.py", line 44, in login raise Exception() Exception

…on code from this library that has run flawlessly for well over a year…

34 def login(self, username, password): 35 initial_csrf = self.__get_csrf_from_home_page(base_url) 36 csrf, auth_level = self.__identify_user(username, initial_csrf) 37 38 if csrf and auth_level: 39 self.__csrf = csrf 40 if auth_level != AuthLevelEnum.USER_REMEMBERED: 41 raise RequireTwoFactorException() 42 self.__authenticate_password(password) 43 else: 44 raise Exception()

Is anyone else experiencing this and/or have a fix/workaround? Tried disabling 2FA, no dice. Have logged a support case with PC but not holding my breath.

Thanks! Ian

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 4
  • Comments: 21

Most upvoted comments

Looks like update in cloudflare, a small homepage structure change, and API payloads. My solution here (new dependency added, cloudscraper): pull request #21

I wonder if @haochi would be willing to assign ownership of this repo to another dev so that we could add this fix?

Was about to come here and make a similar pull request! Thanks for making this. For those coming along trying to fix this for themselves, run the following (assuming you’re using requirements.txt):

pip uninstall personalcapital -y
pip install git+git://github.com/UnusualPi/personalcapital.git@cd0c88f78912c928ad8fafcce05864a43d914d54
pip freeze > requirements.txt
echo 'git+git://github.com/UnusualPi/personalcapital.git@cd0c88f78912c928ad8fafcce05864a43d914d54' >> requirements.txt

Note that there are breaking changes, such as authenticate_password requiring username now, so make sure to update your use of the library if you switch over.

Thanks, @UnusualPi. I applied your fix and it resolved the login error issue on my end. I had to upgrade a couple of required package versions to make it fully work though. Thanks again for the solution!

Thanks @willyiwei - looks like I’m surviving reboots & all is well - thanks to all here for lending a hand.

@Aharic - thanks for the info - that did the trick. (I was close…) 😃

LOL … so took a wild guess that my old OpenBSD box where I host this script is just in some janky state – and so I ported the script to a very recently-created AWS EC2 instance.

*Good news: *no more pkg import errors 😃

Bad news: cloudscraper.exceptions.CloudflareChallengeError: Detected a Cloudflare version 2 Captcha challenge, This feature is not available in the opensource (free) version.

Is anyone else seeing this?

On Wed, Dec 1, 2021 at 10:05 AM Ian Van Hoven @.***> wrote:

Thanks @UnusualPi … still at a loss on this 😦 Any additional suggestion/guidance appreciated.

I made your changes directly in…

/usr/local/lib/python3.4/site-packages/personalcapital/personalcapital.py

…re-confirmed I have cloudscraper…

% sudo pip install cloudscraper Requirement already satisfied: cloudscraper in /usr/local/lib/python3.4/site-packages (1.2.58) Requirement already satisfied: pyparsing>=2.4.7 in /usr/local/lib/python3.4/site-packages (from cloudscraper) (2.4.7) Requirement already satisfied: requests>=2.9.2 in /usr/local/lib/python3.4/site-packages (from cloudscraper) (2.20.0) Requirement already satisfied: requests-toolbelt>=0.9.1 in /usr/local/lib/python3.4/site-packages (from cloudscraper) (0.9.1) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.4/site-packages (from requests>=2.9.2->cloudscraper) (3.0.4) Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python3.4/site-packages (from requests>=2.9.2->cloudscraper) (2.7) Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.4/site-packages (from requests>=2.9.2->cloudscraper) (1.24.3) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.4/site-packages (from requests>=2.9.2->cloudscraper) (2019.9.11)

…but getting the following error when executing my script…

% tail -0f log/2021/wx.log.202112.ad.err [Wed Dec 1 09:29:50 2021] ERROR: Package import failure; exiting… [Wed Dec 1 09:29:50 2021] ERROR: invalid syntax (init.py, line 202) ^C

…with init.py containing the following…

% cat init.py from .personalcapital import PersonalCapital, RequireTwoFactorException, TwoFactorVerificationModeEnum

…yet seeing the following (seemingly good) in STDOUT when running script w/ verbose logging…

% python -v wx.ad.py [ … ]

code object from

/usr/local/lib/python3.4/site-packages/personalcapital/init.py

created

‘/usr/local/lib/python3.4/site-packages/personalcapital/pycache/init.cpython-34.pyc’

wrote

‘/usr/local/lib/python3.4/site-packages/personalcapital/pycache/init.cpython-34.pyc’

code object from

/usr/local/lib/python3.4/site-packages/personalcapital/personalcapital.py

created

‘/usr/local/lib/python3.4/site-packages/personalcapital/pycache/personalcapital.cpython-34.pyc’

wrote

‘/usr/local/lib/python3.4/site-packages/personalcapital/pycache/personalcapital.cpython-34.pyc’

destroy cloudscraper

destroy personalcapital.personalcapital

destroy personalcapital

[ … ]

On Sun, Nov 21, 2021 at 7:14 AM UnusualPi @.***> wrote:

@ianvanhoven https://github.com/ianvanhoven it really depends on your implementation, but you’ll definitely have to install cloudscraper. For the code changes in the personalcapital.py file, you could either edit directly in your python site-packages directory https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory or you could just download the file, include in your script directory, and make the modifications on that file https://csatlas.com/python-import-file-module/. I’d recommend the latter, when you use import in python it looks for files in the same directory before looking in site-packages. Hope that helps!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/haochi/personalcapital/issues/20#issuecomment-974834963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWS5DXBW63BU7SSFVSLC7LUNEED7ANCNFSM5IMRH7SQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.