Lumaktaw sa pangunahing nilalaman
s.id Logo
Tingnan ang Markdown

Pagpapatunay

Dalawang paraan ng pagpapatunay sa s.id API, API key para sa server-to-server, OAuth 2.0 para kumilos sa ngalan ng mga user.

Server-to-server na access

Ang mga API key ay nagpapatunay ng mga server-to-server na integrasyon. Gumawa ng isa sa Dashboard → Developer → API Keys, piliin ang iyong mga scope, at ipasa ito bilang Bearer token.

SaklawAkses
links:readIlista at basahin ang mga link
links:writeGumawa at mag-update ng mga link (gumawa, mag-edit, magbalik)
links:archiveMag-archive ng mga link
links:analyticsBasahin ang click statistics at kabuuang bilang para sa bawat link
qr:readBasahin ang QR code settings (global at bawat link)
qr:writeI-customize ang QR code settings (global at bawat link)
user:readBasahin ang authenticated user profile at account quota
microsites:readBasahin ang mga microsite
microsites:writeGumawa, mag-update, at mamahala ng mga microsite component
microsites:deleteMag-delete ng mga microsite at component nito
bash
Authorization: Bearer sk_live_...
bash
curl https://api.s.id/v2/links \
  -H "Authorization: Bearer sk_live_..."
  • Ang mga key ay nagsisimula sa sk_live_ at isang beses lamang ipinakikita sa paglikha.
  • Humiling lamang ng minimum na mga scope na kailangan ng iyong integrasyon.
  • Bawiin agad ang mga key kapag nakompromiso, gumawa ng bago.
  • Huwag kailanman ilantad ang mga API key sa client-side (mga browser, mobile app).

Authorization flow

I-redirect ang user sa s.id para sa pahintulot, i-verify ang callback state, at ipagpalit ang single-use code sa access token at umiikot na refresh token.

  • Gumawa ng hindi mahuhulaang state value, itago ito sa user session, at tiyaking eksaktong tugma sa callback upang maiwasan ang CSRF.
  • Gumamit ng redirect_uri na eksaktong tumutugma sa nakarehistro para sa iyong OAuth application.

Kailangan ang PKCE, walang client secret

Para sa SPA, mobile app, at CLI. Gumawa ng random na code_verifier, ipadala ang S256 challenge nito sa authorize, at ipadala ang orihinal na verifier sa token exchange.

bash
https://api.s.id/oauth/authorize?
  response_type=code&
  client_id=YOUR_CLIENT_ID&
  redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&
  scope=links%3Aread%20links%3Awrite&
  state=RANDOM_CSRF_VALUE&
  code_challenge=BASE64URL_SHA256_VERIFIER&
  code_challenge_method=S256
bash
curl -X POST https://api.s.id/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "code=AUTHORIZATION_CODE" \
  -d "redirect_uri=https://app.example.com/callback" \
  -d "code_verifier=ORIGINAL_RANDOM_VERIFIER"

Client secret sa pinagkakatiwalaang backend

Para sa server-rendered o backend application na kayang panatilihing lihim ang client_secret. Opsyonal pa rin ang PKCE at inirerekomenda bilang dagdag na depensa.

bash
https://api.s.id/oauth/authorize?
  response_type=code&
  client_id=YOUR_CLIENT_ID&
  redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&
  scope=links%3Aread%20links%3Awrite&
  state=RANDOM_CSRF_VALUE
bash
curl -X POST https://api.s.id/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET" \
  -d "code=AUTHORIZATION_CODE" \
  -d "redirect_uri=https://app.example.com/callback"
Access tokenPaglalarawan
access_tokenMag-e-expire pagkalipas ng 1 oras
refresh_tokenMag-e-expire pagkalipas ng 30 araw
codeIsang beses lang magagamit; mag-e-expire pagkalipas ng 10 minuto
bash
curl -X POST https://api.s.id/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=refresh_token" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "refresh_token=CURRENT_REFRESH_TOKEN"
bash
curl -X POST https://api.s.id/oauth/revoke \
  -H "Content-Type: application/json" \
  -d '{"token":"TOKEN_TO_REVOKE"}'
Discovery at mga token operationPaglalarawan
https://api.s.id/.well-known/oauth-authorization-serverTuklasin ang mga endpoint URL, suportadong scope, at PKCE method sa pamamagitan ng RFC 8414 metadata.
POST /oauth/introspectMaaaring tingnan ng confidential resource server kung aktibo ang token at suriin ang mga scope nito.
POST /oauth/revokeBawiin ang access o refresh token kapag idiniskonekta ng user ang iyong integration.
GET /oauth/userinfoBasahin ang profile na nauugnay sa OAuth access token na may user:read.

Buksan ang Developer Dashboard