tencent cloud

CloudBase

Product Introduction
Product Overview
Features and Strengths
Use Cases
System Limits
Purchase Guide
Product Pricing
Description Of Billing Capability Items
Yearly/Monthly Subscription Package Description
Alarm and Notification
Overdue Payment Instructions
Development Guide
Cloud Storage
Database
Identity Verification
Cloud function
Static website management
SDK Documentation
Client SDK
Server SDKs
Management-side SDK
Product Agreement
Cloud Development Service Level Agreement

Login with Username and Password

PDF
Focus Mode
Font Size
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.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback