kamau1 commited on
Commit
031dbf3
Β·
1 Parent(s): f0372f9

fix(auth): accept refresh_token from JSON body to resolve 422 on refresh endpoint

Browse files
docs/hflogs/runtimeerror.txt CHANGED
@@ -1,62 +1,66 @@
1
- ===== Application Startup at 2025-11-17 20:43:32 =====
2
 
3
  INFO: Started server process [7]
4
  INFO: Waiting for application startup.
5
- INFO: 2025-11-17T20:43:46 - app.main: ============================================================
6
- INFO: 2025-11-17T20:43:46 - app.main: πŸš€ SwiftOps API v1.0.0 | PRODUCTION
7
- INFO: 2025-11-17T20:43:46 - app.main: ============================================================
8
- INFO: 2025-11-17T20:43:46 - app.main: πŸ“¦ Database:
9
- INFO: 2025-11-17T20:43:50 - app.main: βœ“ Connected | 42 tables | 12 users
10
- INFO: 2025-11-17T20:43:50 - app.main: πŸ’Ύ Cache & Sessions:
11
- INFO: 2025-11-17T20:43:51 - app.services.otp_service: βœ… OTP Service initialized with Redis storage
12
- INFO: 2025-11-17T20:43:51 - app.main: βœ“ Redis: Connected
13
- INFO: 2025-11-17T20:43:51 - app.main: πŸ”Œ External Services:
14
- INFO: 2025-11-17T20:43:52 - app.main: βœ“ Cloudinary: Connected
15
- INFO: 2025-11-17T20:43:52 - app.main: βœ“ Resend: Configured
16
- INFO: 2025-11-17T20:43:52 - app.main: βœ“ WASender: Connected
17
- INFO: 2025-11-17T20:43:52 - app.main: βœ“ Supabase: Connected | 6 buckets
18
- INFO: 2025-11-17T20:43:52 - app.main: ============================================================
19
- INFO: 2025-11-17T20:43:52 - app.main: βœ… Startup complete | Ready to serve requests
20
- INFO: 2025-11-17T20:43:52 - app.main: ============================================================
21
  INFO: Application startup complete.
22
  INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
23
- INFO: 10.16.44.145:37577 - "GET / HTTP/1.1" 200 OK
24
- INFO: 10.16.46.24:45460 - "GET / HTTP/1.1" 200 OK
25
- INFO: 10.16.46.24:1762 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
26
- INFO: 10.16.25.6:31446 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
27
- INFO: 10.16.46.24:48793 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
28
- INFO: 10.16.42.67:22859 - "GET /health HTTP/1.1" 200 OK
29
- INFO: 10.16.42.67:1936 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
30
- INFO: 10.16.25.6:27209 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
31
- INFO: 10.16.46.24:1335 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
32
- INFO: 10.16.42.67:29171 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
33
- INFO: 10.16.44.145:36909 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
34
- INFO: 10.16.42.67:23834 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
35
- INFO: 10.16.42.67:59505 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
36
- INFO: 10.16.42.67:50795 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
37
- INFO: 10.16.46.24:11825 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 404 Not Found
38
- INFO: 10.16.25.6:37604 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 404 Not Found
39
- INFO: 10.16.44.145:47141 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
40
- INFO: 10.16.46.24:64513 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
41
- INFO: 10.16.44.145:38615 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
42
- INFO: 10.16.42.67:42721 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
43
- INFO: 10.16.46.24:35181 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
44
- INFO: 10.16.25.6:63466 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
45
- INFO: 10.16.46.24:25589 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
46
- INFO: 10.16.46.24:37663 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
47
- INFO: 10.16.44.145:56302 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
48
- INFO: 10.16.46.24:21692 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
49
- INFO: 10.16.44.145:32276 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
50
- INFO: 10.16.46.24:27347 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
51
- INFO: 10.16.44.145:48020 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
52
- INFO: 10.16.44.145:42994 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
53
- INFO: 10.16.42.67:5739 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 404 Not Found
54
- INFO: 10.16.44.145:48020 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 404 Not Found
55
- INFO: 10.16.44.145:4385 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
56
- INFO: 10.16.1.71:40660 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
57
- INFO: 10.16.33.8:1953 - "GET / HTTP/1.1" 200 OK
58
- ERROR: 2025-11-18T05:38:46 - app.core.supabase_auth: Get user error: invalid JWT: unable to parse or verify signature, token has invalid claims: token is expired
59
- WARNING: 2025-11-18T05:38:46 - app.api.deps: Invalid or expired token
60
- INFO: 10.16.44.154:49117 - "GET /api/v1/auth/me HTTP/1.1" 401 Unauthorized
61
- INFO: 10.16.42.67:32717 - "GET /?logs=container HTTP/1.1" 200 OK
62
- INFO: 10.16.2.183:36502 - "GET /?logs=container HTTP/1.1" 200 OK
 
 
 
 
 
1
+ ===== Application Startup at 2025-11-18 08:59:49 =====
2
 
3
  INFO: Started server process [7]
4
  INFO: Waiting for application startup.
5
+ INFO: 2025-11-18T09:00:04 - app.main: ============================================================
6
+ INFO: 2025-11-18T09:00:04 - app.main: πŸš€ SwiftOps API v1.0.0 | PRODUCTION
7
+ INFO: 2025-11-18T09:00:04 - app.main: ============================================================
8
+ INFO: 2025-11-18T09:00:04 - app.main: πŸ“¦ Database:
9
+ INFO: 2025-11-18T09:00:08 - app.main: βœ“ Connected | 42 tables | 13 users
10
+ INFO: 2025-11-18T09:00:08 - app.main: πŸ’Ύ Cache & Sessions:
11
+ INFO: 2025-11-18T09:00:09 - app.services.otp_service: βœ… OTP Service initialized with Redis storage
12
+ INFO: 2025-11-18T09:00:09 - app.main: βœ“ Redis: Connected
13
+ INFO: 2025-11-18T09:00:09 - app.main: πŸ”Œ External Services:
14
+ INFO: 2025-11-18T09:00:11 - app.main: βœ“ Cloudinary: Connected
15
+ INFO: 2025-11-18T09:00:11 - app.main: βœ“ Resend: Configured
16
+ INFO: 2025-11-18T09:00:11 - app.main: βœ“ WASender: Connected
17
+ INFO: 2025-11-18T09:00:11 - app.main: βœ“ Supabase: Connected | 6 buckets
18
+ INFO: 2025-11-18T09:00:11 - app.main: ============================================================
19
+ INFO: 2025-11-18T09:00:11 - app.main: βœ… Startup complete | Ready to serve requests
20
+ INFO: 2025-11-18T09:00:11 - app.main: ============================================================
21
  INFO: Application startup complete.
22
  INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
23
+ INFO: 10.16.12.18:26269 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
24
+ INFO: 10.16.44.154:44924 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
25
+ INFO: 10.16.12.18:26269 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
26
+ INFO: 10.16.12.18:22464 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
27
+ INFO: 10.16.25.6:1259 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
28
+ INFO: 10.16.2.183:9110 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
29
+ INFO: 10.16.42.67:46793 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
30
+ INFO: 10.16.25.6:8359 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
31
+ INFO: 10.16.2.183:3578 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
32
+ INFO: 10.16.42.67:45252 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
33
+ INFO: 10.16.44.154:42469 - "GET /api/v1/health HTTP/1.1" 404 Not Found
34
+ INFO: 10.16.44.154:42469 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
35
+ INFO: 10.16.2.183:3194 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
36
+ INFO: 10.16.2.183:33060 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
37
+ INFO: 10.16.25.6:30917 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
38
+ INFO: 10.16.44.154:38800 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
39
+ INFO: 10.16.12.18:45701 - "GET /api/v1/health HTTP/1.1" 404 Not Found
40
+ INFO: 10.16.2.183:10285 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
41
+ INFO: 10.16.2.183:49419 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
42
+ INFO: 10.16.42.67:28250 - "GET /api/v1/health HTTP/1.1" 404 Not Found
43
+ INFO: 10.16.12.18:5003 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
44
+ INFO: 10.16.25.6:36117 - "GET /api/v1/health HTTP/1.1" 404 Not Found
45
+ INFO: 10.16.12.18:5003 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
46
+ INFO: 10.16.42.67:53582 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
47
+ INFO: 10.16.44.154:40677 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
48
+ INFO: 10.16.42.67:31017 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
49
+ INFO: 10.16.25.6:5467 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
50
+ INFO: 10.16.44.154:25386 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
51
+ INFO: 10.16.42.67:28837 - "GET /api/v1/health HTTP/1.1" 404 Not Found
52
+ INFO: 10.16.44.154:65418 - "GET /api/v1/health HTTP/1.1" 404 Not Found
53
+ INFO: 10.16.42.67:6962 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
54
+ INFO: 10.16.25.6:17800 - "GET /api/v1/health HTTP/1.1" 404 Not Found
55
+ INFO: 10.16.44.154:56179 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
56
+ INFO: 10.16.44.154:27040 - "GET /api/v1/health HTTP/1.1" 404 Not Found
57
+ INFO: 10.16.2.183:30209 - "GET /api/v1/health HTTP/1.1" 404 Not Found
58
+ INFO: 10.16.42.67:26656 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
59
+ INFO: 10.16.44.154:60538 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
60
+ INFO: 10.16.42.67:22719 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
61
+ INFO: 10.16.45.138:47190 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
62
+ INFO: 10.16.45.138:21893 - "POST /api/v1/auth/refresh-token HTTP/1.1" 422 Unprocessable Entity
63
+ INFO: 10.16.45.138:47190 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
64
+ INFO: 10.16.25.6:49664 - "GET /health HTTP/1.1" 200 OK
65
+ INFO: 10.16.42.67:1809 - "GET / HTTP/1.1" 200 OK
66
+ INFO: 10.16.12.18:8736 - "GET / HTTP/1.1" 200 OK
src/app/api/v1/auth.py CHANGED
@@ -7,7 +7,7 @@ from app.api.deps import get_db, get_current_active_user
7
  from app.core.rate_limit import limiter
8
  from app.schemas.auth import (
9
  LoginRequest, TokenResponse, PasswordChange,
10
- ForgotPasswordRequest, ResetPasswordRequest, MessageResponse
11
  )
12
  from app.schemas.user import (
13
  UserCreate, UserResponse, UserUpdate, UserProfile,
@@ -445,7 +445,7 @@ async def login(request: Request, response: Response, credentials: LoginRequest,
445
 
446
  @router.post("/refresh-token", response_model=TokenResponse)
447
  async def refresh_access_token(
448
- refresh_token: str,
449
  db: Session = Depends(get_db)
450
  ):
451
  """
@@ -477,7 +477,7 @@ async def refresh_access_token(
477
  """
478
  try:
479
  # Refresh session with Supabase
480
- auth_response = await supabase_auth.refresh_session(refresh_token)
481
 
482
  if not auth_response or not auth_response.get("session"):
483
  raise HTTPException(
 
7
  from app.core.rate_limit import limiter
8
  from app.schemas.auth import (
9
  LoginRequest, TokenResponse, PasswordChange,
10
+ RefreshTokenRequest, ForgotPasswordRequest, ResetPasswordRequest, MessageResponse
11
  )
12
  from app.schemas.user import (
13
  UserCreate, UserResponse, UserUpdate, UserProfile,
 
445
 
446
  @router.post("/refresh-token", response_model=TokenResponse)
447
  async def refresh_access_token(
448
+ request_data: RefreshTokenRequest,
449
  db: Session = Depends(get_db)
450
  ):
451
  """
 
477
  """
478
  try:
479
  # Refresh session with Supabase
480
+ auth_response = await supabase_auth.refresh_session(request_data.refresh_token)
481
 
482
  if not auth_response or not auth_response.get("session"):
483
  raise HTTPException(
src/app/schemas/auth.py CHANGED
@@ -37,6 +37,11 @@ class PasswordChange(BaseModel):
37
  return v
38
 
39
 
 
 
 
 
 
40
  class ForgotPasswordRequest(BaseModel):
41
  """Schema for forgot password request"""
42
  email: EmailStr
 
37
  return v
38
 
39
 
40
+ class RefreshTokenRequest(BaseModel):
41
+ """Schema for refresh token request"""
42
+ refresh_token: str = Field(..., min_length=1)
43
+
44
+
45
  class ForgotPasswordRequest(BaseModel):
46
  """Schema for forgot password request"""
47
  email: EmailStr