Skip to content

Tez start

Bu sahifa eng qisqa yo’l. Batafsil tushuntirish OAuth 2.0 qo’llanmasi da.

0. Client oling

client_id va client_secret olish + redirect_uri (callback) ni ro’yxatdan o’tkazish uchun menejerga yozing: PRO GROUP Manager.

1. Foydalanuvchini yo’naltiring

https://id.sfere.pro/oauth?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code

Foydalanuvchi kirib, hisobni tanlab, ruxsat bergach ProID sizning redirect_uriingizga code bilan qaytaradi:

https://yourapp.com/callback?code=AUTH_CODE

2. code ni tokenga almashtiring (backend)

Terminal window
curl -X POST 'https://api.id.sfere.pro/api/v2/oauth/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_id=YOUR_CLIENT_ID' \
--data-urlencode 'client_secret=YOUR_CLIENT_SECRET' \
--data-urlencode 'redirect_uri=YOUR_REDIRECT_URI' \
--data-urlencode 'code=AUTH_CODE'

Javob:

{
"token_type": "Bearer",
"expires_in": 864000,
"access_token": "42|Xr8..."
}

3. Foydalanuvchi ma’lumotini oling

Terminal window
curl 'https://api.id.sfere.pro/api/user' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Tayyor — endi access_token va foydalanuvchi ma’lumoti bilan o’z tizimingizda sessiya yaratishingiz mumkin.