Skip to content

Commit 0a30e16

Browse files
committed
refactor(core): Add null check for IAM API key
1 parent 1f14e00 commit 0a30e16

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamTokenManager.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ public class IamTokenManager {
4545
private static final String REFRESH_TOKEN = "refresh_token";
4646

4747
public IamTokenManager(IamOptions options) {
48-
if (CredentialUtils.hasBadStartOrEndChar(options.getApiKey())) {
49-
throw new IllegalArgumentException("The IAM API key shouldn't start or end with curly brackets or quotes. "
50-
+ "Please remove any surrounding {, }, or \" characters.");
48+
if (options.getApiKey() != null) {
49+
if (CredentialUtils.hasBadStartOrEndChar(options.getApiKey())) {
50+
throw new IllegalArgumentException("The IAM API key shouldn't start or end with curly brackets or quotes. "
51+
+ "Please remove any surrounding {, }, or \" characters.");
52+
}
53+
this.apiKey = options.getApiKey();
5154
}
52-
53-
this.apiKey = options.getApiKey();
5455
this.url = (options.getUrl() != null) ? options.getUrl() : DEFAULT_IAM_URL;
5556
this.userManagedAccessToken = options.getAccessToken();
5657
tokenData = new IamToken();

0 commit comments

Comments
 (0)