User Login API
POST/auth/v1/signin
Login Scenarios Explanation
1. Username/Password Login
Input Requirements:
username: Username (required, 2-48 characters, supports English letters (case-sensitive), numbers, special characters (only -_.:+ @), must start with a letter or number, Chinese characters not supported)password: Password (required)
Prerequisites:
- Registered users can use username/password login
Username/Password Login Request Example
{
"username": "zhangsan",
"password": "example password"
}
Username/Password Login Response Example
{
"token_type": "Bearer",
"access_token": "your_access_token",
"refresh_token": "m.aB3cD4eF5gH6iJ7kL8mN9oP0qR1sT2uV3wX4yZ5aB6cD7eF8gH9iJ0kL1mN2oP3qR4sT5uV6wX7yZ8",
"expires_in": 7200,
"sub": "9876543210123456789"
}
2. Phone Number Verification Code Login
Input Requirements:
verification_token: Verification code token (required), obtained from Verify SMS/Email Verification Code API
Prerequisites:
- Need to call verification code sending API first to get verification code
- Get verification_token after verification code validation passes
Phone Number Verification Code Login Request Example
{
"verification_token": "your_verification_token"
}
Phone Number Verification Code Login Response Example
{
"token_type": "Bearer",
"access_token": "your_access_token",
"refresh_token": "m.aB3cD4eF5gH6iJ7kL8mN9oP0qR1sT2uV3wX4yZ5aB6cD7eF8gH9iJ0kL1mN2oP3qR4sT5uV6wX7yZ8",
"expires_in": 7200,
"sub": "9876543210123456789"
}
3. Email Verification Code Login
Input Requirements:
verification_token: Verification code token (required), obtained from Verify SMS/Email Verification Code API
Prerequisites:
- Need to call email verification code sending API first to get verification code
- Get verification_token after verification code validation passes
Email Verification Code Login Request Example
{
"verification_token": "your_verification_token"
}
Email Verification Code Login Response Example
{
"token_type": "Bearer",
"access_token": "your_access_token",
"refresh_token": "m.aB3cD4eF5gH6iJ7kL8mN9oP0qR1sT2uV3wX4yZ5aB6cD7eF8gH9iJ0kL1mN2oP3qR4sT5uV6wX7yZ8",
"expires_in": 7200,
"sub": "9876543210123456789"
}
General Notes:
- The three login methods are mutually exclusive, only one method can be used per request
- For verification code login, need to obtain verification_token from Verify SMS/Email Verification Code API
- Returns standard token response after successful login
Request
Query Parameters
Client ID corresponding to the application, can be obtained from Cloud Development Platform -> Identity Authentication -> Development Settings. Defaults to environment ID, can be omitted
Header Parameters
Device ID, the ID of the current logged-in device. The client should generate it randomly and cache it on the client. This parameter is related to the number of logged-in accounts.
- application/json
Body
Required when logging in with username and password. 2-48 characters, supports English letters (case-sensitive), numbers, special characters (only -_.:+ @), must start with a letter or number, Chinese characters not supported
Required when logging in with username and password
Required when logging in with verification code. When logging in with phone verification code, the verification code token returned after verification. Obtained through the verify SMS/email verification code API
Responses
- 200
- 400
- 501
Response Headers
- application/json
- Schema
- Example (from schema)
- Example
Schema
Uniformly return Bearer
Token used to access Cloud Development HTTP API, length within 4096 bits
access_token can be refreshed to get a new access_token when it expires through refresh_token, expiration time defaults to 31 days. Length within 128 bits
Expiration time of access_token, in seconds
{
"token_type": "string",
"access_token": "string",
"refresh_token": "string",
"expires_in": 0,
"scope": "string",
"sub": "string",
"groups": [
"string"
]
}
{
"token_type": "Bearer",
"access_token": "your_access_token",
"refresh_token": "m.aB3cD4eF5gH6iJ7kL8mN9oP0qR1sT2uV3wX4yZ5aB6cD7eF8gH9iJ0kL1mN2oP3qR4sT5uV6wX7yZ8",
"expires_in": 7200
}
- invalid_username_or_password, incorrect username or password
- captcha_required, too many login attempts, requires verification code
- password_not_set, user password not set, needs to be set
- invalid_status, account locked due to too many retries, please try again later
Response Headers
X-Request-Id string
Example: 1e55ed89-4a2b-47f8-b7de-27b4775c2adbRequest ID
- application/json
- Schema
- Example (from schema)
- Example
Schema
{
"error": "string",
"error_code": 0,
"error_description": "string"
}
{
"error": "invalid_username_or_password",
"error_code": 4043,
"error_description": "Username or password incorrect."
}
- username login is disabled by admin, username/password login is not enabled, go to https://tcb.cloud.tencent.com to enable identity authentication function
Response Headers
- application/json
- Schema
- Example (from schema)
- Example
Schema
{
"error": "string",
"error_code": 0,
"error_description": "string"
}
{
"error": "unimplemented",
"error_code": 12,
"error_description": "username login is disabled by admin"
}