@@ -902,7 +902,7 @@ func (c *Config) ClientSession() (interface{}, error) {
902902 if sess .BluemixSession .Config .BluemixAPIKey != "" {
903903 err = authenticateAPIKey (sess .BluemixSession )
904904 if err != nil {
905- session .bmxUserFetchErr = fmt .Errorf ("Error occured while fetching account user details: %q" , err )
905+ session .bmxUserFetchErr = fmt .Errorf ("Error occured while fetching auth key for account user details: %q" , err )
906906 session .functionConfigErr = fmt .Errorf ("Error occured while fetching auth key for function: %q" , err )
907907 session .powerConfigErr = fmt .Errorf ("Error occured while fetching the auth key for power iaas: %q" , err )
908908 session .ibmpiConfigErr = fmt .Errorf ("Error occured while fetching the auth key for power iaas: %q" , err )
@@ -920,7 +920,7 @@ func (c *Config) ClientSession() (interface{}, error) {
920920 }
921921
922922 }
923- userConfig , err := fetchUserDetails (sess .BluemixSession , c .Generation )
923+ userConfig , err := fetchUserDetails (sess .BluemixSession , c .Generation , c . RetryCount )
924924 if err != nil {
925925 session .bmxUserFetchErr = fmt .Errorf ("Error occured while fetching account user details: %q" , err )
926926 }
@@ -1681,7 +1681,7 @@ func authenticateCF(sess *bxsession.Session) error {
16811681 return tokenRefresher .AuthenticateAPIKey (config .BluemixAPIKey )
16821682}
16831683
1684- func fetchUserDetails (sess * bxsession.Session , generation int ) (* UserConfig , error ) {
1684+ func fetchUserDetails (sess * bxsession.Session , generation , retries int ) (* UserConfig , error ) {
16851685 config := sess .Config
16861686 user := UserConfig {}
16871687 var bluemixToken string
@@ -1697,6 +1697,12 @@ func fetchUserDetails(sess *bxsession.Session, generation int) (*UserConfig, err
16971697 })
16981698 //TODO validate with key
16991699 if err != nil && ! strings .Contains (err .Error (), "key is of invalid type" ) {
1700+ if retries > 0 {
1701+ if config .BluemixAPIKey != "" {
1702+ _ = authenticateAPIKey (sess )
1703+ return fetchUserDetails (sess , generation , retries - 1 )
1704+ }
1705+ }
17001706 return & user , err
17011707 }
17021708 claims := token .Claims .(jwt.MapClaims )
0 commit comments