diff --git a/auth.go b/auth.go index 18dc847..e4258ae 100644 --- a/auth.go +++ b/auth.go @@ -24,6 +24,7 @@ const ( type Authenticator struct { config *oauth2.Config + token *oauth2.Token context context.Context } @@ -67,6 +68,10 @@ func (a *Authenticator) AuthURLWithOpts(state string, opts ...oauth2.AuthCodeOpt return a.config.AuthCodeURL(state, opts...) } +func (a *Authenticator) GetToken() *oauth2.Token { + return a.token +} + func (a *Authenticator) Token(state string, r *http.Request) (*oauth2.Token, error) { values := r.URL.Query() if e := values.Get("error"); e != "" { @@ -129,6 +134,7 @@ func (a *Authenticator) Authenticate() (*Client, error) { select { case token = <-tokenCh: + a.token = token client = a.NewClient(token) return client, nil diff --git a/client.go b/client.go index 4737eee..b891e39 100644 --- a/client.go +++ b/client.go @@ -144,16 +144,6 @@ func NewClient(host, clientId string, opts *ClientOptions) *Client { return c } -func NewClientRemote(opts *ClientOptions) *Client { - c, err := newClient("https://api.meethue.com/v2/", opts) - if err != nil { - c.logger.Error(err, "Couldn't create client") - return nil - } - - return c -} - // CreateUser creates local user on the bridge and returns authenticated client instance // Don't forget to press bridge button otherwise it will fail func CreateUser(host, deviceType string, opts *ClientOptions) (*Client, error) { diff --git a/light.go b/light.go index 75f3da3..b95407c 100644 --- a/light.go +++ b/light.go @@ -52,6 +52,7 @@ func (s *LightService) GetAll(ctx context.Context) ([]Light, *Response, error) { for k, l := range lights { id, _ := strconv.Atoi(k) l.ID = id + lights[k] = l } return funk.Values(lights).([]Light), resp, nil