Skip to main content

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.

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

Body

    provider_id Identity provider ID, fixed to custom for custom login (string)required
    ticket Custom login ticket (string)required

Responses

Response Headers
    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[]
    Loading...