s.id Logo
s.id
डेवलपर प्लेटफ़ॉर्म

प्रमाणीकरण

s.id API के साथ प्रमाणीकरण के दो तरीके — server-to-server के लिए API keys, उपयोगकर्ताओं की ओर से कार्य करने के लिए OAuth 2.0।

API Keys

API keys server-to-server integrations को authenticate करती हैं। Dashboard → Developer → API Keys में एक बनाएं, scopes चुनें और इसे Bearer token के रूप में पास करें।

Authorization header

Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

उदाहरण request

curl https://api.s.id/v2/links \
  -H "Authorization: Bearer sk_live_..."

उपलब्ध scopes

links:readList and read links
links:writeCreate and update links (create, edit, restore)
links:archiveArchive links
links:analyticsRead per-link click statistics and lifetime counts
qr: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 quota
microsites:readRead microsites
microsites:writeCreate, update, delete and manage components of microsites
  • Keys sk_live_ से शुरू होती हैं और creation के समय केवल एक बार दिखाई जाती हैं।
  • केवल वही minimum scopes मांगें जो आपके integration को चाहिए।
  • compromise होने पर keys तुरंत revoke करें — नई बनाएं।
  • Client-side (browsers, mobile apps) पर API keys कभी expose न करें।

OAuth 2.0

s.id उपयोगकर्ताओं की ओर से कार्य करने के लिए authorization-code flow का उपयोग करें। आपका ऐप उपयोगकर्ता को अनुमोदन के लिए s.id पर redirect करता है, फिर code को access token से exchange करता है।

Authorization flow

  1. 1उपयोगकर्ता को redirect करें
    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
  2. 2Code को token से exchange करें
    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
  3. 3Access token का उपयोग करें
    GET https://app.s.id/oauth/userinfo
      Authorization: Bearer ACCESS_TOKEN

Public client — बिना client secret वाले ऐप्स (SPA, mobile, CLI) — के लिए PKCE (S256) आवश्यक है, और confidential client के लिए वैकल्पिक है। स्टेप 1 में code_challenge और code_challenge_method जोड़ें, और स्टेप 2 में code_verifier जोड़ें। परिणामी access token किसी भी /v2 endpoint पर API key की तरह काम करता है, उपयोगकर्ता द्वारा दिए गए scope के अनुसार।