Authentication
CET uses Supabase Auth. All API calls require this header:Authorization: Bearer <supabase-jwt-token>
Content-Type: application/json
Auth Methods
| Method | Flow |
|---|---|
| Google OAuth | supabase.auth.signInWithOAuth({ provider: 'google' }) |
| GitHub OAuth | supabase.auth.signInWithOAuth({ provider: 'github' }) |
| Email OTP | supabase.auth.signInWithOtp({ email }) then verify 6-digit code |
JWT Verification (FastAPI)
from jose import jwt, JWTError
async def verify_jwt(token: str) -> dict:
payload = jwt.decode(
token.credentials,
SUPABASE_JWT_SECRET,
algorithms=["HS256"],
audience="authenticated" # Must match
)
return payload
OAuth Callback
// app/auth/callback/route.ts
export async function GET(request: Request) {
const code = new URL(request.url).searchParams.get('code')
if (code) await supabase.auth.exchangeCodeForSession(code)
return NextResponse.redirect(new URL('/dashboard', request.url))
}
Error Codes
| HTTP | Code | Meaning |
|---|---|---|
401 | UNAUTHORIZED | Missing or invalid JWT |
403 | FORBIDDEN | Valid JWT but no access to resource |
