envoy_reader icon indicating copy to clipboard operation
envoy_reader copied to clipboard

Add support for 6 month owner tokens through enlighten API, and batte…

Open DanBeard opened this issue 2 years ago • 10 comments

This solves [gh-78] for my newly provisioned system on Firmware version D7.0.71 . I couldn't figure out how to get the token working from the 'entrez' api, but I found a technical brief by enphase on how to get token through enlighten that is good for 6 months. (link here)

This commit adds a new optional use_enlighten_owner_token param. If set it will attempt to log in to enlighten and grab the token from the enlighten API. I also added the ability to add a time buffer so it will refresh before the expiry date. This can be useful for offline use, so if you grab a new token every month you can be sure you'll have ~5 months left if enphase's server or your internet connection goes down.

It seems that the bearer token only works on the '/auth/check_jwt' endpoint. The other endpoints also want the session cookie that is returned by that endpoint or they return 401. So the change to add cookies to the client may also solve 401s with the entrez api tokens (but I couldn't test that because the entrez token generation api doesn't work for me for whatever reason)

I was also missing battery information for my system even though I have a battery backup. I found out from this post that you have to go through the 'ensemble' API for my model. (No idea how they figured that out. Is this API fully documented anywhere?)

I don't think I modified anything in the other data flows but I can't test on any systems but mine. Let me know if this causes any issues

Pull request recommendations:

  • [ ] Name your pull request your-development-type/short-description. Ex: feature/read-tiff-files
  • [ ] Link to any relevant issue in the PR description. Ex: Resolves [gh-12], adds tiff file format support
  • [ ] Provide context of changes.
  • [ ] Provide relevant tests for your feature or bug fix.
  • [ ] Provide or update documentation for any feature added by your pull request.

Thanks for contributing!

DanBeard avatar Mar 02 '22 23:03 DanBeard