Auth Verify (Magic Link Token Verification)
A user clicks the magic link delivered to their email; the app extracts the token and session, submits them to the verify endpoint, and receives a short-lived handoff code in return.
Flow
-
Deep link opens the app — The mobile app intercepts the magic-link URL and parses
email,token, andsessionfrom the query string. -
Client submits verification — A
POSTrequest is sent to the auth-verify Lambda with{ "email", "token", "session" }. -
Input validation — The Lambda normalizes and validates the email. Missing token or session values return HTTP 400 with a specific error code.
-
Cognito challenge response —
admin_respond_to_auth_challengeis called withChallengeName=CUSTOM_CHALLENGEandANSWER=<token>. On success, Cognito returns anAuthenticationResultcontainingAccessToken,IdToken,RefreshToken, andExpiresIn. -
Email verified flag —
admin_update_user_attributessetsemail_verified=trueon the Cognito user. -
Handoff code creation — The
create_handoff_codeORM helper stores the Cognito tokens in the shared PostgreSQL database with a short TTL and returns a single opaque code. -
Response — The API returns
{ "handoffCode": "<code>", "expiresIn": <seconds> }. The mobile app immediately exchanges this code via the handoff endpoint to obtain tokens natively.
Entry Point
- Lambda:
main/server/api/auth/verify/app.py→lambda_handler - HTTP method:
POST /auth/verify(API Gateway)
Dependencies
- AWS Cognito (
COGNITO_USER_POOL_ID,COGNITO_APP_CLIENT_ID) - PostgreSQL via
shared.orm.create_handoff_code
Error Cases
| Condition | Response |
|---|---|
| Invalid email format | 400 AUTH_EMAIL_INVALID |
| Missing token | 400 AUTH_TOKEN_REQUIRED |
| Missing session | 400 AUTH_SESSION_REQUIRED |
| Wrong or expired token | 400 AUTH_TOKEN_INVALID |