연동하기
비바톤 로그인의 상세 구현 페이지입니다. 인증코드 요청 → Redirect 처리 → 토큰 발급 → 사용자 정보 조회까지, 실제 API 호출 4단계를 순서대로 구현합니다.
01 인증코드 요청
비바톤 로그인 화면을 호출하고, 사용자 로그인을 거쳐 인증 코드 발급을 요청합니다. 비바톤 서버에 로그인 세션이 있으면 곧바로 인증 코드를 받고, 없으면 계정 ID·비밀번호 입력 화면이 먼저 노출됩니다.
GET /oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=read_profile&state={STATE}
// 현재 창에서 이동 location.href = "https://bauth.bbaton.com/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=read_profile&state={STATE}"; // 또는 팝업으로 열기 window.open( "https://bauth.bbaton.com/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=read_profile", "bbaton", "width=400, height=500" );
02 Redirect URL로 인증코드 받기
인증 코드 요청의 응답은 redirect_uri로 Redirect되며, 쿼리 스트링에 인증 코드 또는 에러 메시지가 포함됩니다. 성공 시 http://redirect_uri?code={CODE} 형태로 코드가 반환됩니다.
"사이트에 연결할 수 없음" 오류의 대부분은 등록된 redirect_uri와 요청 파라미터 값이 다를 때 발생합니다. 두 값이 완전히 일치하는지 먼저 확인하세요.
03 인증코드로 토큰 요청
인증 코드를 받은 뒤 토큰 요청 API를 호출합니다. 토큰 발급이 완료되어야 사용자 정보를 요청할 수 있습니다. 비바톤 계정 세션의 인증 시간은 기본 24시간이며, 최초 인증 후 변경되지 않습니다.
POST /oauth/token
// Redirect URI로 받은 code로 토큰 교환 const url = "https://bauth.bbaton.com/oauth/token"; const auth = "Basic " + Buffer.from(client_id + ":" + secret_key).toString("base64"); // Body: grant_type=authorization_code&redirect_uri={REDIRECT_URI}&code={CODE} // Header: Authorization: auth
04 토큰으로 사용자 정보 요청
토큰 발급이 완료되면 /v2/user/me로 사용자 정보를 요청합니다. Authorization: {token_type} {access_token} 형태의 헤더를 사용합니다.
GET /v2/user/me
// 3단계에서 받은 token_type, access_token 사용 const url = "https://bapi.bbaton.com/v2/user/me"; const auth = response.data.token_type + " " + response.data.access_token; // Header: Authorization: auth // 응답에는 식별정보 없이 검증값(성인 여부)만 포함됩니다
Node.js, Java, PHP, Python 예제가 각각 제공됩니다. 이 페이지는 핵심 요청 구조를 빠르게 파악할 수 있도록 대표 예시 중심으로 정리했습니다.