Skip to content

Commit d5f31d1

Browse files
committed
fix: Look for iam_apikey in credential file for IAM auth
1 parent e89b299 commit d5f31d1

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

BaseService.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
using IBM.Cloud.SDK.Utilities;
1919
using System;
20-
using System.Collections.Generic;
21-
20+
using System.Collections.Generic;
21+
2222
namespace IBM.Cloud.SDK
2323
{
2424
public class BaseService
@@ -40,7 +40,7 @@ public BaseService(string serviceId)
4040
}
4141
}
4242

43-
string ApiKey = Environment.GetEnvironmentVariable(serviceId.ToUpper() + "_APIKEY");
43+
string ApiKey = Environment.GetEnvironmentVariable(serviceId.ToUpper() + "_IAM_APIKEY");
4444
string Username = Environment.GetEnvironmentVariable(serviceId.ToUpper() + "_USERNAME");
4545
string Password = Environment.GetEnvironmentVariable(serviceId.ToUpper() + "_PASSWORD");
4646
string ServiceUrl = Environment.GetEnvironmentVariable(serviceId.ToUpper() + "_URL");
@@ -78,36 +78,36 @@ public BaseService(string versionDate, Credentials credentials, string serviceId
7878

7979
public BaseService(Credentials credentials, string serviceId) { }
8080

81-
public void WithHeader(string name, string value)
81+
public void WithHeader(string name, string value)
8282
{
83-
if (!customRequestHeaders.ContainsKey(name))
84-
{
85-
customRequestHeaders.Add(name, value);
83+
if (!customRequestHeaders.ContainsKey(name))
84+
{
85+
customRequestHeaders.Add(name, value);
86+
}
87+
else
88+
{
89+
customRequestHeaders[name] = value;
8690
}
87-
else
88-
{
89-
customRequestHeaders[name] = value;
90-
}
9191
}
9292

93-
public void WithHeaders(Dictionary<string, string> headers)
93+
public void WithHeaders(Dictionary<string, string> headers)
9494
{
95-
foreach (KeyValuePair<string, string> kvp in headers)
95+
foreach (KeyValuePair<string, string> kvp in headers)
9696
{
97-
if (!customRequestHeaders.ContainsKey(kvp.Key))
98-
{
99-
customRequestHeaders.Add(kvp.Key, kvp.Value);
97+
if (!customRequestHeaders.ContainsKey(kvp.Key))
98+
{
99+
customRequestHeaders.Add(kvp.Key, kvp.Value);
100100
}
101-
else
102-
{
103-
customRequestHeaders[kvp.Key] = kvp.Value;
104-
}
105-
}
101+
else
102+
{
103+
customRequestHeaders[kvp.Key] = kvp.Value;
104+
}
105+
}
106106
}
107107

108-
protected void ClearCustomRequestHeaders()
109-
{
110-
customRequestHeaders = new Dictionary<string, string>();
108+
protected void ClearCustomRequestHeaders()
109+
{
110+
customRequestHeaders = new Dictionary<string, string>();
111111
}
112112
}
113113
}

0 commit comments

Comments
 (0)