Closed michaelharo closed 3 years ago
Sorry, I was wrong.
My idea was/is to make the authorisation stuff from https://github.com/uhthomas/tesla/blob/master/cmd/login/main.go as reusable as possible, including access to the oauth config. Currently that's not the case, discussion in https://github.com/uhthomas/tesla_exporter/issues/7#issuecomment-777197505. So instead of merging here I'd propose to work with uhthomas to provide a clean interface.
I think the login stuff should exist, but not be part of the NewClient interface as we each have different ways we want to provide login functionality, but once we have an oauth2 access/refresh token I assume everything else is common.
I would like the ability to pass in an HTTP client that is configured for logging (instrumenting its roundtripper). Oauth does that by using the context, so the oauth client could handle authentication, token renewal and logging. The remaining pieces would be documentation how to create that client (using uhthomas) and improving the api of uhthomas.
I think the login stuff should exist
In terms of being duplicated from uhthomas? For what purpose?
As long as the context passed as part of NewClient has the http client associated in it then I think that meets your requirement.
@andig Do you have any additional concerns about this pull request?
LGTM! Should we mention in the README that injecting a client can be done via the context as its not obvious?
Fix #8
@michaelharo you're basically rebuilding the uhthomas library but without the MFA part? Why not just use the OAuth config from there?