@@ -1548,7 +1548,7 @@ func (c *Config) ClientSession() (interface{}, error) {
15481548 kpurl = fileFallBack (fileMap , c .Visibility , "IBMCLOUD_KP_API_ENDPOINT" , c .Region , kpurl )
15491549 }
15501550 var options kp.ClientConfig
1551- if c .BluemixAPIKey != "" {
1551+ if ( c .BluemixAPIKey != "" ) && ( c . IAMTrustedProfileID == "" && c . IAMTrustedProfileName == "" ) {
15521552 options = kp.ClientConfig {
15531553 BaseURL : EnvFallBack ([]string {"IBMCLOUD_KP_API_ENDPOINT" }, kpurl ),
15541554 APIKey : sess .BluemixSession .Config .BluemixAPIKey , // pragma: allowlist secret
@@ -1591,7 +1591,7 @@ func (c *Config) ClientSession() (interface{}, error) {
15911591 kmsurl = fileFallBack (fileMap , c .Visibility , "IBMCLOUD_KP_API_ENDPOINT" , c .Region , kmsurl )
15921592 }
15931593 var kmsOptions kp.ClientConfig
1594- if c .BluemixAPIKey != "" {
1594+ if ( c .BluemixAPIKey != "" ) && ( c . IAMTrustedProfileID == "" && c . IAMTrustedProfileName == "" ) {
15951595 kmsOptions = kp.ClientConfig {
15961596 BaseURL : EnvFallBack ([]string {"IBMCLOUD_KP_API_ENDPOINT" }, kmsurl ),
15971597 APIKey : sess .BluemixSession .Config .BluemixAPIKey , // pragma: allowlist secret
@@ -1621,6 +1621,7 @@ func (c *Config) ClientSession() (interface{}, error) {
16211621 authenticator , err = core .NewIamAssumeAuthenticatorBuilder ().
16221622 SetApiKey (c .BluemixAPIKey ).
16231623 SetIAMProfileID (c .IAMTrustedProfileID ).
1624+ SetURL (EnvFallBack ([]string {"IBMCLOUD_IAM_API_ENDPOINT" }, iamURL )).
16241625 Build ()
16251626 if err != nil {
16261627 log .Fatalf ("Error in authenticating using NewIamAssumeAuthenticatorBuilder. Error: %s" , err )
@@ -1630,6 +1631,7 @@ func (c *Config) ClientSession() (interface{}, error) {
16301631 SetApiKey (c .BluemixAPIKey ).
16311632 SetIAMProfileName (c .IAMTrustedProfileName ).
16321633 SetIAMAccountID (c .Account ).
1634+ SetURL (EnvFallBack ([]string {"IBMCLOUD_IAM_API_ENDPOINT" }, iamURL )).
16331635 Build ()
16341636 if err != nil {
16351637 log .Fatalf ("Error in authenticating using NewIamAssumeAuthenticatorBuilder with trusted profile name. Error: %s" , err )
@@ -3785,6 +3787,7 @@ func newSession(c *Config) (*Session, error) {
37853787 iamURL := EnvFallBack ([]string {"IBMCLOUD_IAM_API_ENDPOINT" }, IAMURL )
37863788 if (c .BluemixAPIKey != "" ) && (c .IAMTrustedProfileID != "" || c .IAMTrustedProfileName != "" ) {
37873789 if c .IAMTrustedProfileID != "" {
3790+ log .Println ("Configuring Session with Trusted Profile ID" )
37883791 authenticator , err = core .NewIamAssumeAuthenticatorBuilder ().
37893792 SetApiKey (c .BluemixAPIKey ).
37903793 SetIAMProfileID (c .IAMTrustedProfileID ).
@@ -3794,6 +3797,7 @@ func newSession(c *Config) (*Session, error) {
37943797 log .Fatalf ("Error in authenticating using NewIamAssumeAuthenticatorBuilder. Error: %s" , err )
37953798 }
37963799 } else {
3800+ log .Println ("Configuring Session with Trusted Profile Name" )
37973801 authenticator , err = core .NewIamAssumeAuthenticatorBuilder ().
37983802 SetApiKey (c .BluemixAPIKey ).
37993803 SetIAMProfileName (c .IAMTrustedProfileName ).
@@ -3806,12 +3810,16 @@ func newSession(c *Config) (*Session, error) {
38063810 }
38073811 } else if c .BluemixAPIKey != "" || c .IAMRefreshToken != "" {
38083812 if c .BluemixAPIKey != "" {
3813+ log .Println ("Configuring Session with API Key" )
38093814 authenticator = & core.IamAuthenticator {
3810- ApiKey : c .BluemixAPIKey ,
3811- URL : iamURL ,
3815+ ApiKey : c .BluemixAPIKey ,
3816+ URL : iamURL ,
3817+ ClientId : "bx" ,
3818+ ClientSecret : "bx" ,
38123819 }
38133820 } else {
38143821 // Construct the IamAuthenticator with the IAM refresh token.
3822+ log .Println ("Configuring Session with refresh token" )
38153823 authenticator = & core.IamAuthenticator {
38163824 RefreshToken : c .IAMRefreshToken ,
38173825 ClientId : "bx" ,
@@ -3820,10 +3828,12 @@ func newSession(c *Config) (*Session, error) {
38203828 }
38213829 }
38223830 } else if strings .HasPrefix (c .IAMToken , "Bearer" ) {
3831+ log .Println ("Configuring Session with access token" )
38233832 authenticator = & core.BearerTokenAuthenticator {
38243833 BearerToken : c .IAMToken [7 :],
38253834 }
38263835 } else {
3836+ log .Println ("Configuring Session with access token" )
38273837 authenticator = & core.BearerTokenAuthenticator {
38283838 BearerToken : c .IAMToken ,
38293839 }
@@ -3950,7 +3960,7 @@ func RefreshToken(sess *bxsession.Session) error {
39503960 if err != nil {
39513961 return err
39523962 }
3953- _ , err = tokenRefresher .RefreshToken ( )
3963+ err = tokenRefresher .FetchAuthorizationData ( config . Authenticator )
39543964 return err
39553965}
39563966
0 commit comments