matt-thurling / MMM-EnphaseSolar

Magic Mirror module for display data from Enphase Solar System
MIT License
3 stars 0 forks source link

Toekn expires after one day #3

Open 0fxyzSa0vj opened 5 days ago

0fxyzSa0vj commented 5 days ago

Access token seems to be expiring everyday now, started 2 days ago. Had been functioning fine for months.

matt-thurling commented 4 days ago

Hi,

  1. Which method did you use to get the token?

  2. Can you please try decoding the token from base64 (paste it into somewhere like https://www.base64decode.org/ and click decode), and then see what value it has for exp i.e. amongst the decoded text will be something like "exp":1741337527. That number is a unix timestamp which you can feed into somewhere like https://www.epochconverter.com/ to convert to a date. This should help figure out whether enphase is giving you a token with a small expiry date or if there's something wrong with how this module is using the token.

Thanks, Matt

0fxyzSa0vj commented 3 days ago

Hi, sorry, was out at work yesterday. I've been using method one for the access token since encountering the issue. Using the links you provided above it does seem like enphase is giving me a short expiry date. I got a new access token on the 14th (probably around 10am) and the token expired at 3am on the 15th.

I'll try method two and see if I'm still getting a small expiry date. I'll report back.

Update: It does seem that method 2 provides a one year expiration on the access token.

matt-thurling commented 2 days ago

Ah, that's good news - glad to hear you've got a longer lasting one now, thanks for reporting back!

In the meantime, I tried googling and checking the enphase forums to see if anything has changed on the enphase side recently, but it doesn't seem to be the case. One thing I did stumble on though was another user whose enphase account had been set up as an "installer" which they suspect lead to the token they got from "Method 1" expiring after 12 hours. Their solution was to create a second account linked to their system and set it up as a "system owner", and then that gave them a 1 year expiry. Not sure if this is the case for your enphase account, but it does mean there might be some difference in token generation depending on enphase account setup - and as you've demonstrated also between which method is used.

I'll keep this issue open for now so that others who encounter it can give the other method a try, and I'll update the README next time I push a change to master to let people know that the expiry dates might differ depending on which method you use.

Thanks again for letting me know that the second method gave the expected result, hopefully it will help others too.