Skip to content

Commit

Permalink
improve credentials null check
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Sep 23, 2024
1 parent 81b66b7 commit c5a8507
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions main.tea
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ api doRPCRequest(action: string, version: string, protocol: string, method: stri
}

if (!Util.equalString(authType, 'Anonymous')) {
if (Util.isUnset(@credential)) {
throw {
code = `InvalidCredentials`,
message = `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`
}
}
var credentialModel = @credential.getCredential();
var credentialType = credentialModel.type;
if (Util.equalString(credentialType, 'bearer')) {
Expand Down Expand Up @@ -405,6 +411,12 @@ api doROARequest(action: string, version: string, protocol: string, method: stri
}

if (!Util.equalString(authType, 'Anonymous')) {
if (Util.isUnset(@credential)) {
throw {
code = `InvalidCredentials`,
message = `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`
}
}
var credentialModel = @credential.getCredential();
var credentialType = credentialModel.type;
if (Util.equalString(credentialType, 'bearer')) {
Expand Down Expand Up @@ -584,6 +596,12 @@ api doROARequestWithForm(action: string, version: string, protocol: string, meth
}

if (!Util.equalString(authType, 'Anonymous')) {
if (Util.isUnset(@credential)) {
throw {
code = `InvalidCredentials`,
message = `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`
}
}
var credentialModel = @credential.getCredential();
var credentialType = credentialModel.type;
if (Util.equalString(credentialType, 'bearer')) {
Expand Down

0 comments on commit c5a8507

Please sign in to comment.