tencent cloud

Login with Username and Password
Last updated:2025-12-31 11:48:17
Login with Username and Password
Last updated: 2025-12-31 11:48:17
Through login with username and password, you can allow your users to bind a username and log in to CloudBase using the username and password.
If the username has not been bound before, you need to complete the login using another login method before you can bind the username. After successful binding, you can log in using the username and password.

Enabling Username and Password Login

Go to the CloudBase Platform, on the Identity Verification > Login Methods page, enable username and password login.

Binding Username Process

Note:
Username binding can only be done during registration.

Step 1: Initializing the SDK

import cloudbase from "@cloudbase/js-sdk";

const app = cloudbase.init({
env: "your-env-id"
});

Step 2: Using Other Methods to Register and Set Username

Before binding a username, the user needs to log in using another method, such as email login or WeChat official account login, but excluding anonymous login.
Using email login as an example, set the username when registering a new user:
const auth = app.auth();
const email = "test@example.com";
auth.signUp({
email: email,
// Refer to the Captcha and verification token obtained during email login.
verification_code: verificationCode,
verification_token: verificationTokenRes.verification_token,
// Set username.
username: "userFromEmail",
// Optional, set password.
password: "password123"
});
Note:
1. It can contain numbers and letters, but cannot be pure numbers.
2. Only - and _ are allowed as symbols, and these two symbols are not allowed at the beginning or end.
3. The length range is [1, 32].
Why should I register using another method before binding a username?
A username can be any string that complies with the rules. To prevent your application from registering too many invalid usernames by malicious users, CloudBase currently does not allow direct registration using a username and password.

Login Process

Step 1: Initializing the SDK

import cloudbase from "@cloudbase/js-sdk";

const app = cloudbase.init({
env: "your-env-id"
});

Step 2: Logging in to CloudBase with Username and Password

const auth = app.auth();
// Log in with username and password.
const loginState = await auth.signIn({
username: "your username",
password: "your password"
});
Note:
The passwords for username login and email login are the same.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback