첫 API 호출
토큰을 발급한 뒤 계좌 실명조회(GET /v2/api/bacverification)를 호출하는 예제입니다. 모든 코드는 서버에서 실행합니다. 값은 더미이며 환경 변수는 직접 설정하세요.
client_id와client_secret으로 토큰을 발급합니다. (인증)Authorization: Bearer {access_token}헤더로 계좌 실명조회를 호출합니다.- 응답의
flag가Y이면 성공입니다.holderName은 은행이 돌려준 예금주명입니다.
ACCESS_TOKEN=$(curl -s -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" | jq -r .access_token)
curl -G "https://gateway.checkone.co.kr/v2/api/bacverification" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ --data-urlencode "bankCode=004" \ --data-urlencode "accountNumber=12345678901234" \ --data-urlencode "identityNo=900101" \ --data-urlencode "accountName=홍길동"import java.util.Map;import org.springframework.http.MediaType;import org.springframework.web.client.RestClient;
public class FirstCall { public static void main(String[] args) { RestClient auth = RestClient.create("https://auth-app.checkone.co.kr"); RestClient gateway = RestClient.create("https://gateway.checkone.co.kr");
Map<?, ?> token = auth.post() .uri("/oauth2/token?grant_type=client_credentials") .headers(h -> h.setBasicAuth( System.getenv("CHECKONE_CLIENT_ID"), System.getenv("CHECKONE_CLIENT_SECRET"))) .contentType(MediaType.APPLICATION_FORM_URLENCODED) .retrieve() .body(Map.class); String accessToken = (String) token.get("access_token");
Map<?, ?> result = gateway.get() .uri(b -> b.path("/v2/api/bacverification") .queryParam("bankCode", "{bankCode}") .queryParam("accountNumber", "{accountNumber}") .queryParam("identityNo", "{identityNo}") .queryParam("accountName", "{accountName}") .build(Map.of( "bankCode", "004", "accountNumber", "12345678901234", "identityNo", "900101", "accountName", "홍길동"))) .headers(h -> h.setBearerAuth(accessToken)) .retrieve() .body(Map.class);
System.out.println("flag=" + result.get("flag") + ", code=" + result.get("code")); }}// Node 18+ (서버 전용 코드)const basic = Buffer.from( `${process.env.CHECKONE_CLIENT_ID}:${process.env.CHECKONE_CLIENT_SECRET}`,).toString('base64');
const tokenRes = 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' },});const { access_token: accessToken } = await tokenRes.json();
const query = new URLSearchParams({ bankCode: '004', accountNumber: '12345678901234', identityNo: '900101', accountName: '홍길동',});const res = await fetch(`https://gateway.checkone.co.kr/v2/api/bacverification?${query}`, { headers: { Authorization: `Bearer ${accessToken}` },});const body = await res.json();// 개인정보가 담긴 응답 전체를 로그에 남기지 않고 결과 코드만 기록합니다.process.stdout.write(`flag=${body.flag} code=${body.code}\n`);