Login Methods
CloudBase provides multiple authentication methods. Before using them, you need to enable the required login methods first. You can manage the enabling and disabling of login methods through either the console or SDK.
Prerequisites
- A CloudBase environment has been created
- Understand the applicable scenarios of different login methods, see Supported Login Methods
Managing via Console
Enable Login Method
- Go to CloudBase Platform/Authentication/Login Methods
- Find the login method you want to enable in the login methods list
- Click the Enable button for the corresponding login method
- Complete the necessary configuration according to the prompts (e.g., WeChat login requires configuring AppID and AppSecret)

Disable Login Method
In the login methods list, find the login method you want to disable and click the Disable button.
⚠️ Note: After disabling a login method, users using that method will not be able to log in. Please operate with caution.
Managing via SDK
Applicable Scenarios
- Need to manage login methods for multiple environments in batch
- Need to manage login configuration in automated processes
- Need to dynamically control login methods in backend services
Supported Login Methods
Manage login methods through Tencent Cloud SDK (tencentcloud-sdk), supporting multiple languages such as Java, Go, JavaScript, etc.
Enabling/disabling login methods via Tencent Cloud SDK only affects CloudBase platform authentication v2 login methods, and will not synchronize with the old console v1 login methods.
If you need to manage v1 login methods, please go to the CloudBase console to operate manually.
Parameter Description
| Parameter Name | Description | Parameter Value | Required |
|---|---|---|---|
| EnvId | CloudBase environment ID | Environment ID string | Yes |
| PhoneNumberLogin | Phone number SMS login | TRUE (enable) / FALSE (disable), only supported in Shanghai region | No |
| AnonymousLogin | Anonymous login | TRUE (enable) / FALSE (disable) | No |
| UsernameLogin | Username and password login | TRUE (enable) / FALSE (disable) | No |
Request Example
{
"EnvId": "your-env-id",
"PhoneNumberLogin": "TRUE",
"AnonymousLogin": "TRUE",
"UsernameLogin": "TRUE"
}
Code Examples
For more usage information, visit Tencent Cloud API Explorer.
- JavaScript
- Go
- Java
const tencentcloud = require("tencentcloud-sdk-nodejs-tcb");
const TcbClient = tencentcloud.tcb.v20180608.Client;
// Instantiate authentication object
// Credentials can be obtained from https://console.cloud.tencent.com/cam/capi
const clientConfig = {
credential: {
secretId: "your-secret-id", // Replace with your SecretId
secretKey: "your-secret-key", // Replace with your SecretKey
},
region: "ap-shanghai", // Region parameter
profile: {
httpProfile: {
endpoint: "tcb.tencentcloudapi.com",
},
},
};
// Instantiate client
const client = new TcbClient(clientConfig);
// Configure login method parameters
const params = {
EnvId: "your-env-id", // Replace with your environment ID
PhoneNumberLogin: "TRUE", // Enable phone number SMS login
AnonymousLogin: "TRUE", // Enable anonymous login
UsernameLogin: "TRUE", // Enable username and password login
};
// Call interface
client.EditAuthConfig(params).then(
(data) => {
console.log("Configuration successful:", data);
},
(err) => {
console.error("Configuration failed:", 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 authentication object
// Credentials can be obtained from https://console.cloud.tencent.com/cam/capi
credential := common.NewCredential(
"your-secret-id", // Replace with your SecretId
"your-secret-key", // Replace with your SecretKey
)
// Instantiate client configuration
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "tcb.tencentcloudapi.com"
// Instantiate client
client, _ := tcb.NewClient(credential, "ap-shanghai", cpf)
// Create request object
request := tcb.NewEditAuthConfigRequest()
// Configure login method parameters
envId := "your-env-id" // Replace with your environment ID
phoneLogin := "TRUE" // Enable phone number SMS login
anonymousLogin := "TRUE" // Enable anonymous login
usernameLogin := "TRUE" // Enable username and password login
request.EnvId = &envId
request.PhoneNumberLogin = &phoneLogin
request.AnonymousLogin = &anonymousLogin
request.UsernameLogin = &usernameLogin
// Call interface
response, err := client.EditAuthConfig(request)
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("Configuration failed: %s\n", err)
return
}
if err != nil {
panic(err)
}
// Output result
fmt.Printf("Configuration successful: %s\n", 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 authentication object
// Credentials can be obtained from https://console.cloud.tencent.com/cam/capi
Credential cred = new Credential(
"your-secret-id", // Replace with your SecretId
"your-secret-key" // Replace with your SecretKey
);
// Instantiate HTTP configuration
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("tcb.tencentcloudapi.com");
// Instantiate client configuration
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// Instantiate client
TcbClient client = new TcbClient(cred, "ap-shanghai", clientProfile);
// Create request object and configure parameters
EditAuthConfigRequest req = new EditAuthConfigRequest();
req.setEnvId("your-env-id"); // Replace with your environment ID
req.setPhoneNumberLogin("TRUE"); // Enable phone number SMS login
req.setAnonymousLogin("TRUE"); // Enable anonymous login
req.setUsernameLogin("TRUE"); // Enable username and password login
// Call interface
EditAuthConfigResponse resp = client.EditAuthConfig(req);
// Output result
System.out.println("Configuration successful: " + AbstractModel.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println("Configuration failed: " + e.toString());
}
}
}
💡 Security Tip: The SecretId and SecretKey in the code are for demonstration purposes only. In actual use, please store and use credentials securely through environment variables or key management services. See Key Security Best Practices.
Notes
- Impact Scope: After disabling a login method, users who have logged in with that method will not be able to log in again, but existing login states will not be affected
- Regional Limitation: Phone number SMS login is currently only supported in Shanghai region
- Key Security: When using SDK method, please keep your SecretId and SecretKey secure and avoid leakage
- Version Compatibility: SDK method manages CloudBase platform authentication v2 version, which is independently managed from the old console v1
FAQ
Q: Will users who are already logged in be affected after disabling a login method?
A: No. Disabling a login method will only block new login requests. The access tokens of logged-in users can still be used normally within their validity period.
Q: Why can't I see the login methods enabled via SDK in the old console?
A: SDK manages CloudBase platform authentication v2 login methods, which is an independent system from the old console v1, and they need to be managed separately.
Q: Can I enable multiple login methods at the same time?
A: Yes. You can enable multiple login methods simultaneously according to business needs, and users can choose any method to log in.