-
Notifications
You must be signed in to change notification settings - Fork 14
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
MyUSPS Login fails #9
Comments
I'm having this issue, too. Let me know if there is anything I can do to help. |
I've tried to solve this on multiple occasions, with no luck. If someone else wants to take a stab at it, please do. |
Maybe the hidden values need to be passed as well?
|
Unfortunately that is not sufficient. |
When I go through step by step within the javascript this data is sent to the URL: "struts.token.name=token&token=24DRONKEQX9HA3VR0UAM0LJ0FDQW9VAM&route=&username=&password=&newPassword=&retypeNewPassword=" not sure if this helps any. |
I think the problem lies within some sort of checksum system they've obfusticated here. Take a look at the login page HTML, there's a bundle function. Here is the encoded and decoded forms (along with a translator): https://gist.github.com/stjohnjohnson/3e2d41c4473e6807d149435fd465b2d1 Note: this is going into the headers of the XHR call |
Yes, that was my conclusion. That value is passed in the http request header to login. I executed some of that code with nodejs, but didn't go too far down that route. |
I was previously able to pass a blank value, but whatever they changed now checks. The JavaScript is part of Google Tag Manager, apparently. |
You know, we could resolve this by using a headless browser that executes javascript. There are ones that work directly in Python: http://jeanphix.me/Ghost.py/ However, that would require HomeAssistant to include pyqt, and I'm not sure if they are up for that. |
Adding myself on this to track this since I'm hitting as well. |
@happyleavesaoc @stjohnjohnson @tchellomello I found some other projects that might help out in getting this working. Let me know if I can be of service. The first link seems to use and possibly this... however, this requires using the USPS API and passing tracking codes in manually as far as I can tell. Thanks! |
I tested out @kylefrost's today's mail code and it does login correctly. Perhaps this is a good approach to getting the same data? |
@brianjking I think Selenium actually executes the Javascript required to get that cookie set properly, which is why it works. We could do the same thing, I guess! It's kind of a heavyweight dependency though. |
I agree it's heavy, but to be honest, it's way more reliable than reverse engineering and less likely to break in the future. Since USPS scraping seems so fragile it might be the better approach looking at the bigger picture. |
@happyleavesaoc @raccettura Yeah, it definitely works to login as well as per my testing. Scraping has never been overly reliable and now entirely broken. The scraping option required a lot of development/debugging from @happyleavesaoc and others which has certainly been frustrating and time consuming I'm certain. It's also one of my favorite Home Assistant components so I'd love to have it back. I think this is the best option for moving forward until USPS releases an API, which may never happen. If nothing else, can anyone maybe help me out in getting this setup as a custom component? It would be hugely appreciated. <3 Thanks! |
I'll work on making a custom component. It'll be my first, but I'll give it a go. |
Selenium is a pretty heavyweight component. How about attempting to execute the JS via Python to get whatever silly data they want for the login? https://github.com/amol-/dukpy |
Hey! Glad todays-mail might help with y'all's issue. It's a pretty quickly written, "hey this seems like a cool idea" thing, so excuse the sloppiness. Side note: It looks like this is being used for a home-assistant component? I've debated setting up home-assistant on my server, what are y'all using it for? Haven't decided if it is worth the effort. |
@kylefrost: Using it to glue together all of the different smart home components I have distributed in my house. Check out my config repo https://github.com/aneisch/home-assistant-config |
@kylefrost Pretty much same as @aneisch said. You can check out my repo here along with an old screen recording of some of my configuration https://github.com/brianjking/homeassistant-config. It's really easy to get started with Home Assistant especially on Raspberry Pi. Hass.io seems great, however, I use the customized Raspbian distribution called Hassbian. Feel free to catch me via an issue on my Home Assistant repo or on twitter if you have any questions. @jcconnell Awesome, I plan on trying to look into making a custom component as well. If you figure it out before I do and get it working, let me know. I'll do the same. @philk I'm open to anything that works. However, I harnessing @kylefrost's work using Selenium is probably a great option as we know it works and should be stable. Again, let me know if there's anything I can do to help out in testing or any research. Even if this doesn't get implemented into the USPS component I really hope to get it setup and working as a custom component. |
Ok, now I'm seeing a post from the Home Assistant forums with someone that worked out a different way of getting this working. https://community.home-assistant.io/t/a-working-usps-component-solved-for-now/41012 I haven't had a chance to try it out yet, however, I might look into it. |
@brianjking that setup appears to scrape your email instead of their website. I'd rather go down the website scraping. |
I think using @kylefrost's route of logging in with Selenium is the best approach with what we have today. |
I'd accept a PR to this repository that adds a Selenium (or otherwise) based approach but implements the same API. |
@philk I tried executing the javascript with a couple of those tools - no luck. I think it relies on a browser environment to properly execute. We could isolate the key generation code, but that's tough since the javascript is obfuscated. |
@happyleavesaoc -- @J-CMartin has an implementation of @kylefrost's working in his HASS install. Trying to get that info so we can do a PR or at least use a custom component. Re: brianjking/homeassistant-config#125 |
I have successfully used selenium to login. I then pass the session cookies to I will test this locally for a few days, and figure out a few webdriver configuration details. If that's all successful, I'll push it for everyone interested to test. |
@brianjking I think that might be your issue. Change the python-myusps version number to 1.3.2 in myusps.py and remove the init.py you put there. |
Confirmed working on my Pi setup w/ HASS. |
@firstof9 What installation method did you use on your Pi? @jcconnell @happyleavesaoc I deleted the
|
@brianjking I did just as you did, but after restarting HA im now getting the same error about split :(
|
@brianjking Your install is busted. I'd recommend entirely removing @firstof9 Try a re-install. That's an error in a dependency ... and should be unrelated to selenium/webdrivers/etc If you want to test the module in isolation (without HASS), use this script from your hass virtual env:
It should print out all your packages in JSON. |
I deleted the files in the
|
@happyleavesaoc Ah there we go, pip3 install --upgrade myusps==1.3.2 downgraded some other component "requests(something)" and seems to have resolved the issue. |
@brianjking try |
@firstof9 |
Brian, can you summarize the steps you took to get this working on your
r-pi with hassbian? I'm a little confused still about chrome/chromium
dependencies...
THanks!
…On 2018-02-16 09:41, Brian J King wrote:
@firstof9 [1] Hassbian does use a venv so inside the active venv I ran
pip3 install --upgrade --force-reinstall myusps==1.3.2 and restarted
Home Assistant and it's working! Thank you @happyleavesaoc [2] and
everyone else!
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub [3], or mute the
thread [4].
*
Links:
------
[1] https://github.com/firstof9
[2] https://github.com/happyleavesaoc
[3]
#9 (comment)
[4]
https://github.com/notifications/unsubscribe-auth/AXdPvkKDJS6JLBnfXh9at7QgiXvTfqH2ks5tVb3NgaJpZM4QLkTy
|
Just FYI:
I have to use
pip3 install --force-reinstall myusps==1.3.2
It doesn't recognize the --reinstall command
On Feb 16, 2018 9:16 AM, "Chris" <notifications@github.com> wrote:
@brianjking <https://github.com/brianjking> try pip3 install --reinstall
myusps==1.3.2 see if it helps
I don't use hassbian so im not sure if you need to do it from a venv or not.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AXYVLaft_7-Cg5MzBMzAvmMprlkWNCmOks5tVbf0gaJpZM4QLkTy>
.
|
activate your venv and run:
That should do it. @brianjking or someone more fimilar with hasbbian would have to fill in how to do the venv bit if you are not sure how to. |
Thanks! I was able to get phantomjs installed and got into the venv and
installed myusps 1.3.2 ok, no errors, but still not able to log into
usps:
"myusps.USPSError: authentication failed".
Wish I understood more to be able to troubleshoot further. But at least
I've got the packages installed ok, I think.
…On 2018-02-16 12:36, Chris wrote:
@n0dyjeff [1]
sudo dpkg -i phantomjs_2.1.1_armhf.deb```
activate your venv and run:
```pip3 install --upgrade --force-reinstall myusps==1.3.2```
That should do it. @brianjking or someone more fimilar with hasbbian
would have to fill in how to do the venv bit if you are not sure how
to.
--
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub [2], or mute the
thread [3].
*
Links:
------
[1] https://github.com/n0dyjeff
[2]
#9 (comment)
[3]
https://github.com/notifications/unsubscribe-auth/AXdPvgXKhIVCXVAWgEFcIAcYf-CQztmaks5tVebHgaJpZM4QLkTy
|
@n0dyjeff Shoot i forgot you have to modify homeassistant/components/usps.py and change the 1.3.0 to 1.3.2 as well, otherwise I think it'll revert to 1.3.0. |
@n0dyjeff Yeah, be sure that you update |
O--KAY!!! That did it. Edited usps.py as mentioned, then did force-reinstall, and I'm logging into usps for the first time in months. Awesome! |
Hey guys, I managed to install phantomjs by following these steps: Then I did a I updated the requirements version to 1.3.2 in When I use the following testscript, and run it with python3, I do get results. However, within HomeAssistant the sensors still throw the following error: `ERROR (MainThread) [homeassistant.setup] Error during setup of component usps 2018-02-16 23:15:17 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: exception=Traceback (most recent call last): , source=components/usps.py, message=Error during setup of component usps, level=ERROR, timestamp=1518851717.1152697` Any ideas what's causing this and how to fix it? |
That script isn't a test script it is part of Home Assistant. The errors in HA look like you didn't add the usps config bits into |
Thanks @firstof9 . I wasn't aware it's suddenly critical to have usps configured in configuration.yaml Moving it back to configuration.yaml indeed solved the isuse. Everything works perfect again. |
I installed an update to phantomjs with the latest Ubuntu updates. It broke USPS. Reverting back to 2.1.1 fixed it. FYI |
@n0dyjeff Hmm, so running CC: @happyleavesaoc |
That's up to you as the system admin. I personally recommend not installing phantomjs via apt at all, so it doesn't know to upgrade it in the first place. Download the binary, and symlink it into your PATH. |
@happyleavesaoc It looks like I had never installed PhantomJS via
However, upon running
CC: @firstof9 & @n0dyjeff -- Either of you have the same findings? Any idea how to disable the install of PhantomJS? Thanks! |
@brianjking Did you only install PhantomJS via pkg? Have you tried any of these techniques? https://tecadmin.net/exclude-packages-from-apt-upgrade/ |
@jcconnell Yeah, I did try those methods. I also only ever installed the |
Hey,
Error in log:
|
Hi all - please only use this issue tracker for issues specifically relating to
Thanks! |
The text was updated successfully, but these errors were encountered: