인증
토큰 발급
섹션 제목: “토큰 발급”POST https://auth-app.checkone.co.kr/oauth2/token?grant_type=client_credentials
| 항목 | 값 |
|---|---|
| 클라이언트 인증 | client_secret_basic: Authorization: Basic base64(client_id:client_secret) |
| 허용 grant | client_credentials만 지원 |
| Content-Type | application/x-www-form-urlencoded |
응답 필드:
| 필드 | 설명 |
|---|---|
access_token |
JWT(RS256) 액세스 토큰 |
token_type |
Bearer |
expires_in |
유효 시간(초). 300 |
scope |
부여된 권한 |
curl -X POST "https://auth-app.checkone.co.kr/oauth2/token?grant_type=client_credentials" \ -u "$CHECKONE_CLIENT_ID:$CHECKONE_CLIENT_SECRET" \ -H "Content-Type: application/x-www-form-urlencoded"import java.util.Map;import org.springframework.http.MediaType;import org.springframework.web.client.RestClient;
public class CheckoneTokenClient { private final RestClient auth = RestClient.create("https://auth-app.checkone.co.kr"); private final String clientId = System.getenv("CHECKONE_CLIENT_ID"); private final String clientSecret = System.getenv("CHECKONE_CLIENT_SECRET");
@SuppressWarnings("unchecked") public Map<String, Object> issueToken() { return auth.post() .uri("/oauth2/token?grant_type=client_credentials") .headers(h -> h.setBasicAuth(clientId, clientSecret)) .contentType(MediaType.APPLICATION_FORM_URLENCODED) .retrieve() .body(Map.class); }}// Node 18+ (서버 전용 코드)const clientId = process.env.CHECKONE_CLIENT_ID;const clientSecret = process.env.CHECKONE_CLIENT_SECRET;
export async function issueToken() { const basic = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); const res = await fetch('https://auth-app.checkone.co.kr/oauth2/token?grant_type=client_credentials', { method: 'POST', headers: { Authorization: `Basic ${basic}`, 'Content-Type': 'application/x-www-form-urlencoded', }, }); if (!res.ok) throw new Error(`토큰 발급 실패: HTTP ${res.status}`); return res.json();}Bearer로 호출
섹션 제목: “Bearer로 호출”발급한 토큰은 모든 API 호출에 Authorization: Bearer {access_token} 헤더로 보냅니다. 쿼리 문자열이나 폼 본문에 토큰을 싣지 않습니다. 휴대폰 본인인증의 브라우저 form 제출만 예외이며 휴대폰 본인인증에서 설명합니다.
권한(scope)
섹션 제목: “권한(scope)”| 대상 | 필요한 권한 |
|---|---|
gateway /v2/** (계좌, 카드, BIN, 휴대폰 본인인증 시작, 문자) |
ALL 또는 PVERIFICATION |
| 인증서 본인인증 init | EVERIFICATION |
| 전자서명/CMS init, 서명 데이터 조회 | ESIGN |
토큰 캐시와 재발급
섹션 제목: “토큰 캐시와 재발급”토큰 유효 시간은 300초입니다. 호출마다 발급하지 말고 서버 메모리에 캐시하고, 만료 30초 전쯤 새로 발급하세요. 응답이 401(토큰 서명·만료 오류)이면 한 번 재발급해 재시도합니다. client_credentials에서는 리프레시 토큰을 쓰지 않습니다.
| HTTP | 의미 |
|---|---|
| 401 | 토큰 서명 오류 또는 만료 |
| 400 | 토큰 형식 오류 |
자세한 내용은 오류 코드를 참고하세요.
