diff --git a/cmd/get_password_token.go b/cmd/get_password_token.go index 0d8170a..4bdb910 100644 --- a/cmd/get_password_token.go +++ b/cmd/get_password_token.go @@ -4,10 +4,10 @@ import ( "code.cloudfoundry.org/uaa-cli/cli" "code.cloudfoundry.org/uaa-cli/config" "code.cloudfoundry.org/uaa-cli/help" + "context" "errors" "github.com/cloudfoundry-community/go-uaa" "github.com/spf13/cobra" - "golang.org/x/oauth2" ) func GetPasswordTokenValidations(cfg config.Config, args []string, username, password string) error { @@ -46,12 +46,10 @@ func GetPasswordTokenCmd(cfg config.Config, clientId, clientSecret, username, pa return errors.New("An error occurred while fetching token.") } - transport := api.AuthenticatedClient.Transport.(*oauth2.Transport) - token, err := transport.Source.Token() - + token, err := api.Token(context.Background()) if err != nil { log.Info("Unable to retrieve token") - return uaa.RequestErrorFromOauthError(err) + return err } activeContext := cfg.GetActiveContext() diff --git a/cmd/refresh_token.go b/cmd/refresh_token.go index cbaae60..1bcdd0e 100644 --- a/cmd/refresh_token.go +++ b/cmd/refresh_token.go @@ -5,10 +5,10 @@ import ( "code.cloudfoundry.org/uaa-cli/config" "code.cloudfoundry.org/uaa-cli/help" "code.cloudfoundry.org/uaa-cli/utils" + "context" "errors" "github.com/cloudfoundry-community/go-uaa" "github.com/spf13/cobra" - "golang.org/x/oauth2" ) func RefreshTokenCmd(cfg config.Config, log cli.Logger, tokenFormat string) error { @@ -29,15 +29,14 @@ func RefreshTokenCmd(cfg config.Config, log cli.Logger, tokenFormat string) erro ) log.Infof("Using the refresh_token from the active context to request a new access token for client %v.", utils.Emphasize(cfg.GetActiveContext().ClientId)) if err != nil { - return uaa.RequestErrorFromOauthError(err) + return err } ctx := cfg.GetActiveContext() - transport := api.AuthenticatedClient.Transport.(*oauth2.Transport) - token, err := transport.Source.Token() + token, err := api.Token(context.Background()) //TODO: stop making this request for a second time if err != nil { - return uaa.RequestErrorFromOauthError(err) + return err } ctx.Token = *token diff --git a/go.mod b/go.mod index acef150..f3010c6 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module code.cloudfoundry.org/uaa-cli go 1.12 require ( - github.com/cloudfoundry-community/go-uaa v0.2.7 + github.com/cloudfoundry-community/go-uaa v0.2.8 github.com/fatih/color v1.7.0 github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/mattn/go-runewidth v0.0.2 // indirect diff --git a/go.sum b/go.sum index 15e1cf3..cde915a 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/cloudfoundry-community/go-uaa v0.2.7 h1:3M+b7JrzNcatZJwVnKXQeudkyosB1UPu4zI1VrDtmhc= -github.com/cloudfoundry-community/go-uaa v0.2.7/go.mod h1:5Cb7KTQLqX5Nn7cUd6ksPfnbfIp1g/j5Oo7nHeD0d3Q= +github.com/cloudfoundry-community/go-uaa v0.2.8 h1:jXRea4uJ8Bul5SABS4cqSZWuXPEw8e8EUyD5rqJp43E= +github.com/cloudfoundry-community/go-uaa v0.2.8/go.mod h1:5Cb7KTQLqX5Nn7cUd6ksPfnbfIp1g/j5Oo7nHeD0d3Q= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=