OAuth callback (Google / Apple)
The Cognito Hosted UI's redirect_uri after a Google or Apple sign-in, started at GET /cognito/oauth/{provider}. Not called by API clients directly.
Exchanges code for tokens, provisions or links the profile, sets the access_token, id_token and refresh_token httpOnly cookies, and redirects to the redirect path given when the flow was started (carried in the oauth_flow cookie, not in state), or the frontend root.
A connect round trip (started by POST /cognito/sign-in-methods/{provider}/connect) ends here too, and differently: no session cookie is set and no profile is created or moved. The browser is redirected to the returnPath the connect was started with, with connect_provider and connect_result in the query: connected, email_mismatch (the provider account uses another address), email_not_verified, identity_in_use, cancelled, session_changed (the browser is no longer signed in to the account that started it), expired, or failed. An address is never put in that URL; GET /cognito/sign-in-methods answers it as lastConnect.
Every failure is also a redirect, to {FRONTEND_URL}/auth?error=…: state_mismatch (no oauth_flow cookie in this browser, or state does not match it), unverified_account_exists (a provider identity linked to a native account whose address was never verified), blocked_email_domain (the address fails the sign-up email policy), email_linked_elsewhere (a profile at this address belongs to another sign-in, and this one has not proven the address), missing_code, token_exchange_failed, invalid_token, oauth_error (with a message), or the provider's own error with a message.
Parameters
Query Parameters
Authorization code from Cognito.
The sign-in's one-time nonce, which must match the oauth_flow cookie that GET /cognito/oauth/{provider} set in this browser.
Responses
Redirect — on success to the redirect path the sign-in was started with (or /) on the frontend, with the session cookies set; on failure to /auth?error=… on the frontend.