Skip to content

Commit

Permalink
Fix issue IBM-Cloud#837
Browse files Browse the repository at this point in the history
  • Loading branch information
hkantare committed Nov 7, 2019
1 parent f446324 commit 19d605d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ibm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ func (c *Config) ClientSession() (interface{}, error) {
session.powerConfigErr = fmt.Errorf("Error occured while fetching the auth key for power iaas: %q", err)
session.ibmpiConfigErr = fmt.Errorf("Error occured while fetching the auth key for power iaas: %q", err)
}
err = authenticateCF(sess.BluemixSession)
if err != nil {
session.bmxUserFetchErr = fmt.Errorf("Error occured while fetching account user details: %q", err)
session.functionConfigErr = fmt.Errorf("Error occured while fetching auth key for function: %q", err)
session.isConfigErr = fmt.Errorf("Error occured while fetching auth key for vpc: %q", err)
session.powerConfigErr = fmt.Errorf("Error occured while fetching the auth key for power iaas: %q", err)
session.ibmpiConfigErr = fmt.Errorf("Error occured while fetching the auth key for power iaas: %q", err)
}
}

if sess.BluemixSession.Config.IAMAccessToken != "" && sess.BluemixSession.Config.BluemixAPIKey == "" {
Expand Down Expand Up @@ -578,6 +586,19 @@ func authenticateAPIKey(sess *bxsession.Session) error {
return tokenRefresher.AuthenticateAPIKey(config.BluemixAPIKey)
}

func authenticateCF(sess *bxsession.Session) error {
config := sess.Config
tokenRefresher, err := authentication.NewUAARepository(config, &rest.Client{
DefaultHeader: gohttp.Header{
"User-Agent": []string{http.UserAgent()},
},
})
if err != nil {
return err
}
return tokenRefresher.AuthenticateAPIKey(config.BluemixAPIKey)
}

func fetchUserDetails(sess *bxsession.Session) (*UserConfig, error) {
config := sess.Config
user := UserConfig{}
Expand Down

0 comments on commit 19d605d

Please sign in to comment.