dbrand666 / usmobile-lifeguard

Minds your USMobile pool so you don't have to
GNU General Public License v3.0
15 stars 2 forks source link

Automatically get new JWT as necessary #2

Closed matthewadams closed 1 year ago

matthewadams commented 1 year ago

Add username & password as config values, then get a new JWT from endpoint POST /web-gateway/api/v1/auth with JSON body {"username":"blah","password":"blargy"} whenever the configured token is either blank or has expired. The returned payload is JSON of the form {"jwtToken":"ey..."}.

NOTE: This would require that the user turn off 2FA until such time as usmobile.com supports API tokens w/refresh capabilities.

dbrand666 commented 1 year ago

I really don't want to encourage anyone to turn off 2FA. I wonder if we can do something to make it easier to get the auth token though.

uj commented 1 year ago

A couple of things here:

This issue in general raises the question: how often does the token expire? If I manually get the token from the chrome dev tools, based on the readme instructions, how long is that token good for before I have to do that again and put a new token in the config?

As far as not wanting to disable 2fa, can a valid token (before it expires) be used to get a new token? If so, go that route. Authenticate with the existing token every xx days or whatever before the expiration, grab the new token, replace it in the config. So, you would only need to do get the token manually the first time (or if you don't renew it in time).

dbrand666 commented 1 year ago

I've been running https://github.com/dbrand666/DataRemaining for close to a year and have rarely had to update the token. Maybe twice? Once was after changing my password so it doesn't really count.

Make sure you generate the token in a private window. Logging out accidentally, which might happen in your main session, will certainly invalidate the token.

I guess I'm saying token expiration hasn't been an issue for me so I haven't put the time into it. I would like to make the setup simpler though.

dbrand666 commented 1 year ago

Ok. It just got me while I was on vacation. It's time to do something about it.