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 dc87c9a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 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 Expand Up @@ -816,6 +834,12 @@ api doRequest(params: Params, request: OpenApiRequest, runtime: Util.RuntimeOpti
__request.headers.x-acs-content-sha256 = hashedRequestPayload;

if (!Util.equalString(params.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 authType = credentialModel.type;
if (Util.equalString(authType, 'bearer')) {
Expand Down

0 comments on commit dc87c9a

Please sign in to comment.