github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/actor/v2action/auth.go (about) 1 package v2action 2 3 import "fmt" 4 5 // Authenticate authenticates the user in UAA and sets the returned tokens in 6 // the config. 7 // 8 // It unsets the currently targeted org and space whether authentication 9 // succeeds or not. 10 func (actor Actor) Authenticate(config Config, username string, password string) error { 11 config.UnsetOrganizationInformation() 12 config.UnsetSpaceInformation() 13 14 accessToken, refreshToken, err := actor.UAAClient.Authenticate(username, password) 15 if err != nil { 16 config.SetTokenInformation("", "", "") 17 return err 18 } 19 20 accessToken = fmt.Sprintf("bearer %s", accessToken) 21 config.SetTokenInformation(accessToken, refreshToken, "") 22 return nil 23 }