OAuth Flow Overview

CP-Auth implements the standard OAuth 2.0 Authorization Code Flow with PKCE (RFC 7636). External services choose between two entry-point modes.

Two UX modes

ModeWhat the user seesWhen to useGuide
Self-hosted loginOnly your app (no CP branding)You need full brand controlSelf-hosted login
CP-hosted pageThe auth.cp-platform.com login pageFastest integration with the least codeCP-hosted login page

Both modes share the same backend token-exchange step. The only difference is where the user sees the login UI.

Standard flow (Authorization Code + PKCE)

[1] User      → clicks "Sign in"
[2] App FE    → sends the user to CP-Auth or your own form
[3] User      → authenticates with email/password or a social provider
[4] CP-Auth   → redirects back to your callback URL with ?code=<authcode>&state=<csrf>
[5] App FE    → forwards the code to your backend
[6] App BE    → POST /oauth/token (client_secret + code + code_verifier)
[7] CP-Auth   → { access_token, refresh_token, expires_in }
[8] App BE    → stores access_token in an HttpOnly cookie and responds to the user

Who handles PKCE

FlowPKCE verifier storageVerifier passed at token exchange
Google / Kakao socialCP-Auth (server-side cookie)Not needed — CP-Auth handles it
Email direct authExternal client (SDK does it automatically)Required — send code_verifier to your backend
CP-hosted page redirectCP-Auth (cookie)Not needed

You only need to thread code_verifier through your backend in the self-hosted email flow. The SDK puts it in the onSuccess callback for you.

state · CSRF protection

The state parameter is used in every flow. The SDK generates and validates a random state automatically. If you call the endpoints directly, generate state yourself and verify equality on the callback.

Where to read next