Skip to content

Commit

Permalink
Fix the issue of loading IAM endpoints either for stage or file
Browse files Browse the repository at this point in the history
  • Loading branch information
hkantare committed Dec 11, 2024
1 parent d35f348 commit 51acb7b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1567,10 +1567,20 @@ func (c *Config) ClientSession() (interface{}, error) {

var authenticator core.Authenticator

if c.BluemixAPIKey != "" {
authenticator = &core.IamAuthenticator{
ApiKey: c.BluemixAPIKey,
URL: EnvFallBack([]string{"IBMCLOUD_IAM_API_ENDPOINT"}, "https://iam.cloud.ibm.com") + "/identity/token",
if c.BluemixAPIKey != "" || sess.BluemixSession.Config.IAMRefreshToken != "" {
if c.BluemixAPIKey != "" {
authenticator = &core.IamAuthenticator{
ApiKey: c.BluemixAPIKey,
URL: EnvFallBack([]string{"IBMCLOUD_IAM_API_ENDPOINT"}, iamURL),
}
} else {
// Construct the IamAuthenticator with the IAM refresh token.
authenticator = &core.IamAuthenticator{
RefreshToken: sess.BluemixSession.Config.IAMRefreshToken,
ClientId: "bx",
ClientSecret: "bx",
URL: EnvFallBack([]string{"IBMCLOUD_IAM_API_ENDPOINT"}, iamURL),
}
}
} else if strings.HasPrefix(sess.BluemixSession.Config.IAMAccessToken, "Bearer") {
authenticator = &core.BearerTokenAuthenticator{
Expand Down

0 comments on commit 51acb7b

Please sign in to comment.