CP Platform Developer Guide

How to use CP as your authentication server, take payments through CP-Pay, and send notifications via CP-Notify.

5-minute Quickstart

1. Register an app

Create a new app in the cp-platform.com/developers console. You'll receive:

ValueUsed forExposure
client_idOAuth request identifierPublic (safe in frontend)
client_secretOAuth token exchangeSecret (server-side only)
api_keyCP-Pay / CP-Notify callsSecret (server-side only)
webhook_secretWebhook HMAC verificationSecret (server-side only)

Add redirect_uris to your app settings. You can register both a local URL like http://localhost:3000/auth/callback and your production URL.

2. Install the SDK + add the OAuth guard

npm i git+https://github.com/Copark-Dev/cp-auth-sdk.git#v0.5.2

Mount the provider once at app root:

import { CpAuthProvider } from "@cp-platform/auth-sdk/react";
 
<CpAuthProvider strict>
  <App />
</CpAuthProvider>

One line at every OAuth click:

import { useCpAuth } from "@cp-platform/auth-sdk/react";
 
function LoginButton() {
  const { guardOAuth } = useCpAuth();
  return (
    <button onClick={() => {
      if (guardOAuth("google") !== "proceed") return; // in-app handled
      window.location.href = `https://auth.cp-platform.com/oauth/authorize?client_id=...`;
    }}>Continue with Google</button>
  );
}

guardOAuth auto-detects Threads / Toss / KakaoBank / Coupang / Baemin / Karrot / Discord and 30+ other in-app browsers, escaping Android via Chrome intent and showing an "Open in Safari" modal on iOS. Full flow: Self-hosted login.

3. Exchange code → token in your backend

SDK helpers do the OAuth token exchange:

your-app/api/auth/token.ts
import { CpServerClient } from "@cp-platform/auth-sdk/server";
 
const cp = new CpServerClient(); // authUrl defaults to https://auth.cp-platform.com
 
export async function POST(req: Request) {
  const { code, codeVerifier } = await req.json();
  const tokens = await cp.exchangeOAuthCode(code, codeVerifier);
  const user = await cp.getUserInfo(tokens.access_token);
  // map user.sub to your DB profiles.cp_user_id (federated identity)
  return Response.json(tokens);
}

JWT verification with verifyCpJwt (auto Supabase JWKS / ES256):

import { verifyCpJwt } from "@cp-platform/auth-sdk/jwt";
const { cpUserId, email } = await verifyCpJwt(bearerToken);

4. Take payments (optional)

Use CP-Pay for one-off or subscription payments. See CP-Pay Direct or Subscriptions.

5. Send notifications (optional)

Send email, SMS, Kakao AlimTalk, or push from a single API. See CP-Notify.


Next