diff --git a/service.go b/service.go index 17b614d1..75de60fa 100644 --- a/service.go +++ b/service.go @@ -250,8 +250,8 @@ func (s *service) registerAuthAccount() error { if err != nil { return err } - s.Options().Auth.Init(auth.ClientToken(token)) + s.Options().Auth.Init(auth.ClientToken(token), auth.Credentials(acc.ID, acc.Secret)) logger.Infof("Auth [%v] Authenticated as %v", s.Options().Auth, name) return nil } diff --git a/util/wrapper/wrapper.go b/util/wrapper/wrapper.go index 8dde56f0..285a775f 100644 --- a/util/wrapper/wrapper.go +++ b/util/wrapper/wrapper.go @@ -181,6 +181,16 @@ func (a *authWrapper) Call(ctx context.Context, req client.Request, rsp interfac return callWithToken(tok.AccessToken) } + // generate a new token if we have credentials + if len(aaOpts.ID) > 0 && len(aaOpts.Secret) > 0 { + tok, err := aa.Token(auth.WithCredentials(aaOpts.ID, aaOpts.Secret)) + if err != nil { + return err + } + aa.Init(auth.ClientToken(tok)) + return callWithToken(tok.AccessToken) + } + // check to see if a token was provided in config, this is normally used for // setting the token when calling via the cli if token, err := config.Get("micro", "auth", "token"); err == nil && len(token) > 0 {