🛡️ 모든 과정은 tungkao에서 끝납니다: 사용자는 Twitch로 로그인한 뒤 항상 tungkao로 먼저 돌아오고, 실제 로그인 성공(또는 로그인 중 취소) 시에만 당신의 링크로 보냅니다 — 링크를 직접 연 사람은 tungkao 페이지만 봅니다. '회원'에서 🌐 도메인(인증)과 ↩️ 돌아갈 링크를 설정하세요.
제공 정보: name, email, avatar
📋 진행 방법
제공자 키를 만든 뒤 '로그인 회원'에서 사이트 이름과 돌아갈 주소(https, 정확히 일치)를 설정하세요.
로그인 버튼은 사용자를 client_id(키 ID), redirect_uri, state(매번 새 무작위 값, 세션에 저장)와 함께 /oauth/authorize로 보냅니다.
사용자가 redirect_uri?code=…&state=…로 돌아오면 state 확인 → 서버가 2분 안에 POST /v1/login/token 호출.
data.user(예: 7F3K9QX2-yourshopcom)를 회원 ID로 쓰세요 — 같은 사람은 항상 같은 ID.
📡 API 호출 + 코드 예제
POST/v1/login/token
curl -X POST https://api.tungkao.com/v1/login/token \
-H "Authorization: Bearer $TUNGKAO_KEY" \
-H "Content-Type: application/json" \
-d '{"code":"from the redirect","redirect_uri":"https://yourshop.com/auth/callback"}'
// Node.js 18+ (nothing to install)
const res = await fetch("https://api.tungkao.com/v1/login/token", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.TUNGKAO_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"code": "from the redirect",
"redirect_uri": "https://yourshop.com/auth/callback"
}),
});
const data = await res.json();
console.log(data);
One site, 2 keys of the same provider (e.g. website + app, both Google)
Both keys: Combined (default)
The same person gets the same user ID in both ✅
One site, 2 keys of the same provider, counted as separate accounts
Both keys: Separate
The same person gets a different user ID on each key
2 sister sites sharing members
Both keys: Group A
A member has the same user ID on both sites ✅
2 unrelated sites that must not link members
Both keys: Separate
Different user IDs, so the sites can't link their members ✅
A Google key and a LINE key (different providers)
Any setting
Always different user IDs — they are different provider accounts
A key that already has sign-ins needs a different group
Not allowed (locked 🔒)
Create a new key in the wanted group, so member IDs on your site never change
Set it on the “Sign-in user IDs between keys” card on the API Keys page before go-live (new keys default: Combined). Several keys may use the same domain.
전체 예제 (버튼 + 콜백 + code 교환)
// npm i express express-session
import express from "express";
import session from "express-session";
import crypto from "node:crypto";
const KEY = process.env.TUNGKAO_KEY; // API key (tk_live_…) server-side only
const CLIENT_ID = process.env.TUNGKAO_CLIENT_ID; // the key id (shown in the portal), not a secret
const REDIRECT = "https://yourshop.com/auth/callback"; // must match the registered URL exactly
const app = express();
app.use(session({ secret: process.env.SESSION_SECRET, resave: false, saveUninitialized: false, cookie: { secure: true, sameSite: "lax" } }));
// 1) your "Sign in" button links here
app.get("/auth/login", (req, res) => {
req.session.state = crypto.randomBytes(24).toString("base64url");
const u = new URL("https://api.tungkao.com/oauth/authorize");
u.search = new URLSearchParams({ client_id: CLIENT_ID, redirect_uri: REDIRECT, state: req.session.state });
res.redirect(u);
});
// 2) the user comes back with a code
app.get("/auth/callback", async (req, res) => {
if (!req.query.state || req.query.state !== req.session.state) return res.status(400).send("state mismatch");
delete req.session.state;
if (req.query.error) return res.redirect("/login?cancelled=1");
// 3) exchange the code for the user (within 2 minutes)
const r = await fetch("https://api.tungkao.com/v1/login/token", {
method: "POST",
headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ code: req.query.code, redirect_uri: REDIRECT }),
});
const j = await r.json();
if (!j.success) return res.status(400).send(j.error.message);
req.session.user = j.data; // j.data.user = permanent member id, e.g. 7F3K9QX2-yourshopcom
res.redirect("/");
});
app.listen(3000);
<?php
// login.php — your "Sign in" button links to this file
session_start();
$CLIENT_ID = getenv("TUNGKAO_CLIENT_ID");
$REDIRECT = "https://yourshop.com/callback.php";
$_SESSION["state"] = bin2hex(random_bytes(24));
header("Location: https://api.tungkao.com/oauth/authorize?" . http_build_query([
"client_id" => $CLIENT_ID, "redirect_uri" => $REDIRECT, "state" => $_SESSION["state"],
]));
<?php
// callback.php — the user comes back here
session_start();
$REDIRECT = "https://yourshop.com/callback.php";
if (empty($_GET["state"]) || !hash_equals($_SESSION["state"] ?? "", $_GET["state"])) { http_response_code(400); exit("state mismatch"); }
unset($_SESSION["state"]);
if (!empty($_GET["error"])) { header("Location: /login.php?cancelled=1"); exit; }
$ch = curl_init("https://api.tungkao.com/v1/login/token");
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("TUNGKAO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(["code" => $_GET["code"], "redirect_uri" => $REDIRECT]),
]);
$j = json_decode(curl_exec($ch), true);
if (!$j["success"]) { http_response_code(400); exit($j["error"]["message"]); }
$_SESSION["user"] = $j["data"]; // $j["data"]["user"] = permanent member id
header("Location: /");
# pip install flask requests
import os, secrets, requests
from urllib.parse import urlencode
from flask import Flask, session, request, redirect, abort
app = Flask(__name__)
app.secret_key = os.environ["SESSION_SECRET"]
KEY = os.environ["TUNGKAO_KEY"]
CLIENT_ID = os.environ["TUNGKAO_CLIENT_ID"]
REDIRECT = "https://yourshop.com/auth/callback"
@app.get("/auth/login")
def login():
session["state"] = secrets.token_urlsafe(24)
return redirect("https://api.tungkao.com/oauth/authorize?" + urlencode({"client_id": CLIENT_ID, "redirect_uri": REDIRECT, "state": session["state"]}))
@app.get("/auth/callback")
def callback():
if not request.args.get("state") or not secrets.compare_digest(request.args["state"], session.pop("state", "")):
abort(400)
if request.args.get("error"):
return redirect("/login?cancelled=1")
r = requests.post("https://api.tungkao.com/v1/login/token", headers={"Authorization": f"Bearer {KEY}"},
json={"code": request.args["code"], "redirect_uri": REDIRECT}, timeout=30).json()
if not r["success"]:
abort(400, r["error"]["message"])
session["user"] = r["data"] # r["data"]["user"] = permanent member id
return redirect("/")
제공자
서비스
제공 정보
Google
google_login
이름, 인증된 이메일, 사진
LINE
line_login
이름, 사진, 이메일(동의 시)
Facebook
facebook_login
이름, 사진, 이메일
TikTok
tiktok_login
닉네임, 아바타 (이메일 없음)
Discord
discord_login
이름, 아바타, 이메일
Telegram
telegram_login
name, username, photo
X (Twitter)
x_login
name, username, photo
Microsoft
microsoft_login
name, email (Hotmail/Outlook)
GitHub
github_login
name, email, avatar
Apple
apple_login
permanent member ID (no name or email in this mode)
Steam
steam_login
name, avatar and SteamID (no email)
Twitch
twitch_login
name, email, avatar
LinkedIn
linkedin_login
name, email, photo
Kakao
kakao_login
name, photo (email once Kakao approves it)
NAVER
naver_login
name, email, photo
Zalo
zalo_login
name, photo (no email)
Spotify
spotify_login
name, email, photo
Reddit
reddit_login
username, avatar (no email)
GitLab
gitlab_login
name, email, avatar
Roblox
roblox_login
name, avatar (no email)
Epic Games
epicgames_login
display name (no email)
Yahoo
yahoo_login
name, email, photo
Slack
slack_login
name, email, photo
Amazon
amazon_login
name, email
📚 사용 예시
예시 1
A “Sign in with Twitch” button on your site
상황: A visitor taps Sign in with Twitch on your site
요청
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz
➡️ The user signs in with Twitch and returns to redirect_uri with a code and the same state
예시 2
Exchange the code for the user (server side)
상황: Your server receives the code on the callback page (exchange within 2 minutes)
요청
POST /v1/login/token
{
"code": "<code from the callback>",
"redirect_uri": "https://yourshop.com/auth/callback"
}
➡️ Same user every time → look up the member and sign them in
예시 4
One site, two Twitch keys (website + app)
상황: Separate keys for website and app, same members
➡️ Keep both keys “Combined” (default) before go-live → same user for the same person. Choose “Separate” to keep them apart
예시 5
List members who signed in
상황: You want to browse or search members of this key
요청
GET /v1/login/users?q=somchai&limit=50
➡️ Returns members with last sign-in time and count
예시 6
The user cancels during sign-in
상황: The user cancels on the Twitch screen
➡️ Returns to redirect_uri with error instead of code; show a retry button
💡 더 보기
User IDs between keys: new keys default to “Combined (whole account)”, so the same person signing in through keys of the same provider in one account gets the same ID. Change it to group A–E or “Separate” on the API Keys page before the first sign-in; after that the group is locked so member IDs never change.
로그인 성공 시마다, 그리고 신규 회원당 한 번 크레딧이 차감됩니다 — 현재 가격은 서비스 카드 참고.
test 모드 키는 http://localhost 리디렉션을 허용하며 무료입니다.
API 키를 링크나 페이지에 넣지 마세요 — /oauth/authorize에는 공개 가능한 client_id(키 ID)만 필요합니다.
📜 이 API의 업데이트 기록
추가태국 시간 (UTC+07:00)
🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.
개선태국 시간 (UTC+07:00)
🌐 The sign-in page and the phone-model sign-in help now support all 10 API languages (th, en, lo, my, zh-CN, ko, ja, vi, km, id), picked from the device language or &lang= on the sign-in link, with a language switcher at the bottom
개선태국 시간 (UTC+07:00)
📱 The sign-in help page now names the visitor's exact phone model (e.g. Galaxy S24 Ultra), adds model search, and refreshes the Android model list daily from Google Play — new models get a “New” badge
추가태국 시간 (UTC+07:00)
📱 Step-by-step “sign-in doesn't continue” help by phone brand and model (iPhone, iPad, Samsung, Huawei, HONOR, Xiaomi, OPPO, vivo, realme, OnePlus, Pixel, other Android), with the brand guessed from the device and a link from the sign-in page
추가태국 시간 (UTC+07:00)
Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their group
추가태국 시간 (UTC+07:00)
15 new sign-in providers: Apple, Steam, Twitch, LinkedIn, Kakao, NAVER, Zalo, Spotify, Reddit, GitLab, Roblox, Epic Games, Yahoo, Slack, Amazon. Same /oauth/authorize link and POST /v1/login/token as every existing provider (each one goes on sale when ready; see the services page)
추가태국 시간 (UTC+07:00)
API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
추가태국 시간 (UTC+07:00)
error.user_message: ready-to-show text for end users on outages, no credits or key problems (white-label keys omit tungkao.com)
추가태국 시간 (UTC+07:00)
GET /status: 서비스별 API 상태 (키 불필요)
추가태국 시간 (UTC+07:00)
키 켜기/끄기 스위치와 상태 변경 시각 + 웹사이트당 서비스별 키 1개
개선태국 시간 (UTC+07:00)
API v1 영구 고정(추가만 가능) + X-Tungkao-Api-Version header + 12개월 사전 지원 종료 알림
문서태국 시간 (UTC+07:00)
API별 문서 페이지와 AI 링크 (10개 언어)
보안태국 시간 (UTC+07:00)
API 키별 도메인 인증 (키 1개 = 사이트 1개) — 기존 키는 그대로 작동
추가태국 시간 (UTC+07:00)
선택형 HMAC 요청 서명 — 켜지 않으면 변화 없음
추가태국 시간 (UTC+07:00)
API 키 기간·만료 알림·갱신 — 키 문자열은 그대로
추가태국 시간 (UTC+07:00)
모든 서비스에 test 모드 키 (모의, 무료)
✅ 기존 코드 그대로 작동
🛡️ 안정성 약속: 한 번 연동하면 계속 작동
API /v1은 영구 고정: 삭제·이름 변경·타입 변경 없음 — 새 필드나 엔드포인트만 추가됩니다. 기존 코드를 깨는 배포는 자동 계약 테스트가 막습니다.
제공자(은행, LINE, Google, Facebook, TikTok, Discord, Telegram, 블록체인)가 바뀌면 저희 서버에서 대응합니다 — 코드는 그대로. 영수증 확인은 3개 제공자 간 자동 전환됩니다.
미래에도 안전한 코드: 모르는 필드는 무시하고, 메시지가 아닌 error.code로 분기하며, 모르는 새 status는 '미통과/대기'로 처리하세요.
무언가를 종료해야 한다면 최소 12개월 전에 모든 응답의 Deprecation / Sunset header, 이메일, webhook으로 알립니다 — 그때까지 기존 동작은 유지됩니다.
모든 응답에 버전과 최신 개정일이 담긴 X-Tungkao-Api-Version header가 있습니다. 전체 기록: /changelog.json
🚦 시스템 상태 (GET /status)
API 정상 여부를 언제든 확인 — 키 불필요
GET https://api.tungkao.com/status
🟢 ok = 정상
🟠 busy = 이용자 많음
🔴 slow = 약간 지연
최근 5분 실제 요청 기준, 서비스별(services[]) 측정. 영수증 확인/입금은 모든 백업 제공자를 합산하며 경로별 상태는 routes[]
API 키 불필요, 브라우저에서 호출 가능(CORS 허용), 15초 캐시 — 1분에 한 번 이하로 조회 권장
busy/slow일 때 타임아웃을 15–20초로 늘리고 같은 Idempotency-Key로 재시도하세요 — 중복 과금 없음