tronikos / opower

A Python library for getting historical and forecasted usage/cost from utilities that use opower.com such as PG&E
Apache License 2.0
54 stars 49 forks source link

Fix exception handling during evergy login #7

Closed akoebbe closed 1 year ago

akoebbe commented 1 year ago

Evergy responds differently between a bad username/password and a bad login verification token. If it responds with a 500, then the token is bad. If it responds with a 200 (go figure) then the username and password combo is bad. If it responds with a 302 (redirecting to the account page), then the login was successful.

This PR fixes the login failure handling to use the return status codes.

I'm not sure how I was seeing a 302 with a redirect to the login page when it failed before, but I can't reproduce it now. So I took that "location" header check out of the code.

akoebbe commented 1 year ago

Just noticed the conflict. Working on it now.

akoebbe commented 1 year ago

@tronikos Ready for review.