BBaton/ docs

연동하기

비바톤 로그인의 상세 구현 페이지입니다. 인증코드 요청 → Redirect 처리 → 토큰 발급 → 사용자 정보 조회까지, 실제 API 호출 4단계를 순서대로 구현합니다.

Authorize URL/oauth/authorize
Token URL/oauth/token
User API/v2/user/me
Scoperead_profile

01 인증코드 요청

비바톤 로그인 화면을 호출하고, 사용자 로그인을 거쳐 인증 코드 발급을 요청합니다. 비바톤 서버에 로그인 세션이 있으면 곧바로 인증 코드를 받고, 없으면 계정 ID·비밀번호 입력 화면이 먼저 노출됩니다.

URL

GET /oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=read_profile&state={STATE}

파라미터
설명
필수
비고
client_id
API 신청 후 받은 Client ID
Yes
클라이언트 식별값
redirect_uri
사전 등록된 Redirect URI
Yes
등록값과 완전 일치 필요
response_type
code
Yes
인증코드 방식
scope
read_profile
Yes
기본 사용값
state
클라이언트 상태값
Optional
CSRF 방지 용도
RedirectPopup
Request · 01COPY
// 현재 창에서 이동
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} 형태로 코드가 반환됩니다.

Troubleshooting

"사이트에 연결할 수 없음" 오류의 대부분은 등록된 redirect_uri와 요청 파라미터 값이 다를 때 발생합니다. 두 값이 완전히 일치하는지 먼저 확인하세요.

03 인증코드로 토큰 요청

인증 코드를 받은 뒤 토큰 요청 API를 호출합니다. 토큰 발급이 완료되어야 사용자 정보를 요청할 수 있습니다. 비바톤 계정 세션의 인증 시간은 기본 24시간이며, 최초 인증 후 변경되지 않습니다.

URL

POST /oauth/token

헤더/바디
설명
비고
Authorization
Basic 인증
Base64(client_id:secret_key)
필수
grant_type
인가 방식
authorization_code
필수
redirect_uri
사전 등록 URI
등록값과 동일
필수
code
Redirect 단계에서 받은 코드
{CODE}
필수
Node.js
Request · 02COPY
// 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} 형태의 헤더를 사용합니다.

URL

GET /v2/user/me

Generic
Request · 03COPY
// 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
// 응답에는 식별정보 없이 검증값(성인 여부)만 포함됩니다
Tip

Node.js, Java, PHP, Python 예제가 각각 제공됩니다. 이 페이지는 핵심 요청 구조를 빠르게 파악할 수 있도록 대표 예시 중심으로 정리했습니다.