Custom Login
POST/auth/v1/signin/custom
Applicable Scenarios
- One-to-one mapping between enterprise's own account system and CloudBase account system
- Business scenarios that require completely customized authentication processes
- Need to achieve seamless integration between your own account system and CloudBase services
Function Description
1. Server-side Issued Ticket
Developers need to use the CloudBase SDK on the server side to issue login credentials (Ticket), which are used for subsequent client authentication.
- Refer to Custom Login Documentation for the part before obtaining the ticket.
Code Example:
const cloudbase = require("@cloudbase/node-sdk");
// 1. Initialize SDK
const app = cloudbase.init({
env: "your-env-id",
// Pass custom login private key
credentials: require("/path/to/your/tcb_custom_login.json")
});
// 2. Developer-defined unique user identifier
const customUserId = "your-customUserId";
// 3. Create ticket
const ticket = app.auth().createTicket(customUserId);
// 4. Return ticket to client
return ticket;
2. Client-side Custom Login
API Description
The client uses the server-issued Ticket to obtain access credentials.
Request Example:
{
"provider_id": "custom",
"ticket": "cd7382ee-2f2f-4edf-831e-2f7c68ed3b43/@@/eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhbGciOiJSUzI1NiIsImVudiI6ImJlZ2luZ3JvdXAtMWc2czgyZTIwNWY5ODNjMCIsImlhdCI6MTc1ODU5NzQ4NzY5MSwiZXhwIjo"
}
Key Features:
- access_token is valid for 7200 seconds (2 hours)
- refresh_token is valid for 2592000 seconds (30 days)
- It is recommended to implement an automatic token refresh mechanism
Request
Query Parameters
client_id string
Client ID corresponding to the application, defaults to environment ID, can be omitted
Header Parameters
x-device-id string
Device ID
- application/json
Body
provider_id Identity provider ID, fixed to custom for custom login (string)required
ticket Custom login ticket (string)required
Responses
- 200
Response Headers
- application/json
- Schema
- Example (from schema)
Schema
token_type Access token type (string)
Uniformly return Bearer
access_token User's access token (string)
Token used to access Cloud Development HTTP API, length within 4096 bits
refresh_token User's refresh token (string)
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
expires_in int32
Expiration time of access_token, in seconds
scope Authorization scope (string)
sub User's unique ID (string)
groups string[]
{
"token_type": "string",
"access_token": "string",
"refresh_token": "string",
"expires_in": 0,
"scope": "string",
"sub": "string",
"groups": [
"string"
]
}
Loading...