Files
autoreg-skills-max/skills/lobehub-pool/references/better-auth-api.md

54 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Better Auth API — LobeHub Self-Hosted
## Endpoints
```
POST /api/auth/sign-up/email — регистрация
POST /api/auth/sign-in/email — логин
GET /api/auth/session — сессия (требует cookie)
```
## Sign-Up
```python
import httpx
r = httpx.post("http://[REDACTED-IP]:3210/api/auth/sign-up/email",
json={"email": "[REDACTED-EMAIL]", "password": "Str0ng!Pass", "name": "username"},
headers={
"Origin": "http://[REDACTED-IP]:3210",
"Referer": "http://[REDACTED-IP]:3210/signin?referral=fQXk8Gr5",
"Content-Type": "application/json"
},
timeout=15
)
# 200 → {"token": "...", "user": {"id": "user_xxx", "email": "...", ...}}
# 400 → {"message": "Missing or null Origin", "code": "MISSING_OR_NULL_ORIGIN"}
# 429 → {"message": "Too many requests..."}
```
## Sign-In (валидация)
```python
r = httpx.post("http://[REDACTED-IP]:3210/api/auth/sign-in/email",
json={"email": "[REDACTED-EMAIL]", "password": "Str0ng!Pass"},
headers={"Origin": "http://[REDACTED-IP]:3210", "Referer": "http://[REDACTED-IP]:3210/signin"},
timeout=10
)
# 200 → {"token": "...", "user": {...}}
# 401 → invalid credentials
```
## Rate Limit
- 3-4 регистрации за burst → 429 "Too many requests"
- Пауза 15-30 секунд
- ~40 аккаунтов за 5 минут при sequential режиме
- Rate limit per-IP, не per-email
## Pitfalls
1. **Origin/Referer headers обязательны** — без них 400 MISSING_OR_NULL_ORIGIN
2. **Referer с referral параметром** — передаёт реферальный код при регистрации
3. **Email не верифицируется** — можно использовать любые email адреса
4. **Token в ответе НЕ Bearer** — это session token, передаётся в cookie, не в Authorization header