Store account credentials
This commit is contained in:
parent
3fac7d79ab
commit
47c1cb433e
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user