Skip to main content

Managing Login Methods

CloudBase provides multiple authentication methods, which can be flexibly configured according to your business requirements.

Enable Login Methods via the Console

First, navigate to TCB/Authentication/Login Methods and select the desired login method.

Enable Login Methods via SDK

Support for enabling and disabling login methods via Tencent Cloud SDK (tencentcloud-sdk), with compatibility for multiple languages including Java, Go, and JavaScript.

Tip:

Using the Tencent Cloud SDK (tencentcloud-sdk) to enable/disable login methods will only enable the login methods for TCB platform login authentication v2 and will not simultaneously enable/disable the login methods for the legacy TCB console v1. To enable/disable v1 login methods, please go to the TCB console and perform the operation manually.

Supported login methods and parameters:

Login MethodParameterParameter Value
Phone number Captcha loginPhoneNumberLoginOnly supported in the Shanghai region, TRUE, FALSE, TRUE represents enable, FALSE represents disable
Anonymous LoginAnonymousLoginTRUE, FALSE, TRUE represents enable, FALSE represents disable
Username and Password LoginUsernameLoginTRUE, FALSE, TRUE represents enable, FALSE represents disable
{
"EnvId": "your-env-id",
"PhoneNumberLogin": "TRUE",
"AnonymousLogin": "TRUE",
"UsernameLogin": "TRUE"
}

Sample code is provided below. For more usage examples, visit Tencent Cloud API:

const tencentcloud = require("tencentcloud-sdk-nodejs-tcb");
const TcbClient = tencentcloud.tcb.v20180608.Client;

// Instantiate an authentication object. The input parameters need to include Tencent Cloud account SecretId and SecretKey. Pay attention to keeping the confidentiality of the key pair.
// Code leakage may lead to the leakage of SecretId and SecretKey, threatening the security of all resources under the account. The following sample code is for reference only. It is recommended to use keys in a more secure way. See https://cloud.tencent.com/document/product/1278/85305.
// The key can be obtained at the official console https://console.cloud.tencent.com/cam/capi.
const clientConfig = {
credential: {
secretId: "",
secretKey: "",
},
region: "",
profile: {
httpProfile: {
endpoint: "tcb.tencentcloudapi.com",
},
},
};

// Instantiate a client object for the product to be requested. clientProfile is optional.
const client = new TcbClient(clientConfig);
const params = {};
client.EditAuthConfig(params).then(
(data) => {
console.log(data);
},
(err) => {
console.error("error", err);
}
);