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.
Mga API Key
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.
Authorization header
Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHalimbawa ng request
curl https://api.s.id/v2/links \
-H "Authorization: Bearer sk_live_..."
Mga available na scope
links:readList and read linkslinks:writeCreate and update links (create, edit, restore)links:archiveArchive linkslinks:analyticsRead per-link click statistics and lifetime countsqr:readRead QR code settings (global and per-link)qr:writeCustomize QR code settings (global and per-link)user:readRead the authenticated user profile and account quotamicrosites:readRead micrositesmicrosites:writeCreate, update, delete and manage components of microsites- •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).
OAuth 2.0
Gamitin ang authorization-code flow para kumilos para sa mga user ng s.id. Ang iyong app ay nagre-redirect ng user sa s.id para sa pag-apruba, pagkatapos ay pinapalitan ang code ng access token.
Authorization flow
- 1I-redirect ang user
GET https://dash.s.id/oauth/authorize ?client_id=YOUR_CLIENT_ID &redirect_uri=https://yourapp.com/callback &response_type=code &scope=links:read links:write &state=RANDOM_STATE &code_challenge=CODE_CHALLENGE &code_challenge_method=S256 - 2Palitan ang code ng token
POST https://app.s.id/oauth/token Content-Type: application/x-www-form-urlencoded grant_type=authorization_code &code=AUTH_CODE &redirect_uri=https://yourapp.com/callback &client_id=YOUR_CLIENT_ID &client_secret=YOUR_CLIENT_SECRET &code_verifier=CODE_VERIFIER - 3Gamitin ang access token
GET https://app.s.id/oauth/userinfo Authorization: Bearer ACCESS_TOKEN
Kailangan ang PKCE (S256) para sa mga public client — app na walang client secret (SPA, mobile, CLI) — at opsyonal para sa confidential client. Idagdag ang code_challenge at code_challenge_method sa hakbang 1, at code_verifier sa hakbang 2. Ang access token na nabuo ay gumagana tulad ng API key sa anumang /v2 endpoint, ayon sa scope na ibinigay ng user.