Skip to content

Kích hoạt Soft OTP ​

Kích hoạt SmartOTP trên một thiết bị và trả về khóa bí mật của client (client secret key) cùng cấu hình TOTP mà SDK cần để tạo mã.

Endpoint ​

http
POST /api/v1/saas-sotp/activate
Content-Type: application/json
json
{
  "partner_id": "{{partner_id}}",
  "partner_key": "{{partner_key}}",
  "user_id": "{{user_id}}",
  "device_id": "{{device_id}}",
  "device_os": "{{device_os}}",
  "app_version": "{{app_version}}",
  "registration_id": "{{registration_id}}",
  "activation_key": "{{activation_key}}",
  "push_token": "{{push_token}}",
  "token": "{{token}}",
  "metadata": {
    "ios": "test",
    "version": "test"
  }
}

Tham số:

Tham sốKiểuBắt buộcMặc địnhMô tả
partner_idstringCó—Partner ID.
partner_keystringCó—Partner key.
user_idstringCó—User ID.
push_tokenstringCó—Firebase token của client, dùng để push khóa challenge từ server đến client.
tokenstringCó—Token đăng ký được tạo bởi Đăng ký.
activation_keystringCó—Activation key được tạo bởi Đăng ký. Nó hoạt động giống một mã OTP — hãy gọi lại Đăng ký để lấy một key mới trước khi thử lại.
registration_idstringKhông—Registration ID từ Đăng ký.
device_idstringKhông—UUID của thiết bị.
device_osstringKhông—Hệ điều hành của thiết bị.
app_versionstringKhông—Phiên bản ứng dụng client.
metadataobjectKhông—Thông tin key-value bổ sung để lưu cùng với lần kích hoạt.

Trả về: ActivateResponse

INFO

Endpoint là /api/v1/saas-sotp/activate. Hãy liên hệ đội CAKE nếu bạn gặp lỗi 404.

Ví dụ request ​

bash
curl --location --request POST '<BASE_URL>/saas-sotp/activate' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data-raw '{
    "partner_id": "{{partner_id}}",
    "partner_key": "{{partner_key}}",
    "user_id": "{{user_id}}",
    "device_id": "{{device_id}}",
    "device_os": "{{device_os}}",
    "app_version": "{{app_version}}",
    "registration_id": "{{registration_id}}",
    "activation_key": "{{activation_key}}",
    "push_token": "{{push_token}}",
    "token": "{{token}}",
    "metadata": {
      "ios": "test",
      "version": "test"
    }
  }'

Response ​

json
{
  "success": true,
  "code": 1,
  "message": "success",
  "data": {
    "key": "fake_client_secret_key",
    "period": 15,
    "algorithm": "HmacSHA512",
    "length": 6,
    "type": "totp",
    "issuer": "SOTP"
  }
}
TrườngKiểuMô tả
successboolTrạng thái của request.
codeintstatus code — 1 khi thành công.
data.keystringKhóa bí mật của client dùng để tạo OTP.
data.periodintSố giây một OTP còn hiệu lực.
data.algorithmstringThuật toán HMAC — HmacSHA512.
data.lengthintSố chữ số của một mã OTP.
data.typestringLoại soft OTP — totp.
data.issuerstringIssuer đã tạo ra OTP.

WARNING

key là khóa bí mật của client. Hãy chuyển thẳng nó cho SDK, nơi lưu nó phía sau PIN của người dùng — không bao giờ ghi log, không bao giờ lưu ở phía server cùng bản ghi người dùng, và không bao giờ trả về cho bất kỳ bên gọi nào khác ngoài thiết bị đang kích hoạt. Bất kỳ ai nắm được nó đều có thể tạo OTP cơ bản hợp lệ vô thời hạn.

Lỗi ​

MãMô tả
3Parameter invalid
103Thông tin Partner không chính xác — Partner details are incorrect.
121Yêu cầu vượt giới hạn. Vui lòng thử lại sau ít phút. — Request limit exceeded.
123Yêu cầu vượt giới hạn. Vui lòng thử lại sau ít phút. — Request limit exceeded.
124OTP không hợp lệ — Invalid OTP. activation_key không khớp.
125OTP hết hạn sử dụng — OTP expired. Hãy gọi Đăng ký để lấy một activation key mới.
126Có lỗi xảy ra vui lòng thử lại — An error occurred, please retry.
129Token không hợp lệ — Invalid token.

Bước tiếp theo ​

Developers