Manage Login Methods
CloudBase provides multiple identity authentication methods. You can flexibly configure them according to your business needs.
Enable login methods on the console
First, navigate to CloudBase/Authentication/Login Methods to choose the required login method.

Enabling Login Methods via SDK
Supports management of enabling and disabling login methods via Tencent Cloud SDK (tencentcloud-sdk), and supports multiple languages such as Java, Go, JavaScript.
Enabling/disabling login methods via the Tencent Cloud SDK (tencentcloud-sdk) only activates the CloudBase Platform Login Authentication v2 login methods and does not synchronize the enabling/disabling of the legacy CloudBase Console v1 login methods. To enable/disable v1 login methods, navigate to the CloudBase Console and perform the operation manually.
Supported login methods and parameters:
| Login Methods | Parameters | Parameter Values |
|---|---|---|
| Mobile Phone Verification Code Login | PhoneNumberLogin | TRUE, FALSE; TRUE represents enable, FALSE represents disable |
| Anonymous Login | AnonymousLogin | TRUE, FALSE; TRUE represents enable, FALSE represents disable |
| Username and Password Login | UsernameLogin | TRUE, FALSE; TRUE represents enable, FALSE represents disable |
{
"EnvId": "your-env-id",
"PhoneNumberLogin": "TRUE",
"AnonymousLogin": "TRUE",
"UsernameLogin": "TRUE"
}
Sample code is provided below. To learn more about usage, visit Tencent Cloud API:
- JavaScript
- Go
- Java
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);
}
);
package main
import (
"fmt"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
tcb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tcb/v20180608"
)
func main() {
// 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.
credential := common.NewCredential(
"",
"",
)
// Instantiate a client option, which is optional and can be skipped if there are no special requirements.
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "tcb.tencentcloudapi.com"
// Instantiate a client object for the product to be requested; clientProfile is optional.
client, _ := tcb.NewClient(credential, "", cpf)
// Instantiate a request object; each API corresponds to one request object.
request := tcb.NewEditAuthConfigRequest()
// The returned resp is an instance of EditAuthConfigResponse, corresponding to the request object.
response, err := client.EditAuthConfig(request)
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
// Output a JSON-formatted string response.
fmt.Printf("%s", response.ToJsonString())
}
package com.tencent;
import com.tencentcloudapi.common.AbstractModel;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.tcb.v20180608.TcbClient;
import com.tencentcloudapi.tcb.v20180608.models.*;
public class Sample {
public static void main(String [] args) {
try {
// 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.
Credential cred = new Credential("", "");
// Instantiate an http option, which is optional and can be skipped if there are no special requirements.
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("tcb.tencentcloudapi.com");
// Instantiate a client option, which is optional and can be skipped if there are no special requirements.
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// Instantiate a client object for the product to be requested; clientProfile is optional.
TcbClient client = new TcbClient(cred, "", clientProfile);
// Instantiate a request object; each API corresponds to one request object.
EditAuthConfigRequest req = new EditAuthConfigRequest();
// The returned resp is an instance of EditAuthConfigResponse, corresponding to the request object.
EditAuthConfigResponse resp = client.EditAuthConfig(req);
// Output a JSON-formatted string response.
System.out.println(AbstractModel.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
}