본문으로 건너뛰기

인증 (OAuth)

Gency Open API의 OAuth 2.0 Authorization Code Flow를 안내합니다. 인가 요청과 사용자 동의, authorization code 교환으로 액세스 토큰을 발급받는 과정을 단계별로 정리했습니다.

OAuth Flow​

Gency는 OAuth 2.0 표준을 따르며, 사용자가 앱에 권한을 부여하는 안전한 인가 흐름을 제공합니다.

Authorization Code Flow​

가장 권장되는 방식으로, 3단계로 진행됩니다.

인가 요청​

사용자를 Gency 인가 페이지로 리다이렉트합니다.

GET https://openapi.gency.ai/oauth/authorize
?response_type=code
&client_id={client_id}
&redirect_uri={redirect_uri}
&scope=product:read product:write
&state={random_state}
  • response_type: code (필수)
  • client_id: API 센터에서 발급받은 Client ID (필수)
  • redirect_uri: API 센터에 등록한 Redirect URI (필수)
  • scope: 요청할 권한 (공백으로 구분, 생략 시 앱에 등록된 전체 스코프 사용)
  • state: CSRF 방지용 랜덤 문자열 (권장)

Gency는 이 요청을 받으면 authorize_key를 생성하고, 사용자를 Gency OAuth 로그인/동의 페이지(https://gency.ai/oauth/authorize?authorize_key=...)로 리다이렉트합니다.

사용자 로그인 및 동의​

사용자는 Gency OAuth 페이지에서 이메일/비밀번호로 로그인합니다. 로그인 후 앱 이름, 요청 스코프 등의 정보를 확인하고 동의합니다.

Authorization Code 수신 및 토큰 교환​

사용자가 동의하면 Gency는 등록된 redirect_uri로 authorization code를 전달합니다.

{redirect_uri}?code={authorization_code}&state={state}

이 코드를 사용하여 Access Token을 요청합니다.

POST https://openapi.gency.ai/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code
&code={authorization_code}
&redirect_uri={redirect_uri}
&client_id={client_id}
&client_secret={client_secret}

성공 시 응답:

{
"access_token": "eyJhbGciOi...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "eyJhbGciOi...",
"scope": "product:read product:write"
}

Token 갱신​

Access Token이 만료되면 Refresh Token으로 갱신할 수 있습니다.

POST https://openapi.gency.ai/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token
&refresh_token={refresh_token}
&client_id={client_id}
&client_secret={client_secret}

Token 검증​

발급받은 토큰의 유효성을 확인합니다.

POST https://openapi.gency.ai/oauth/introspect
Content-Type: application/x-www-form-urlencoded

token={access_token}
&client_id={client_id}
&client_secret={client_secret}

Token 폐기​

더 이상 사용하지 않는 토큰을 무효화합니다.

POST https://openapi.gency.ai/oauth/revoke
Content-Type: application/x-www-form-urlencoded

token={token}
&client_id={client_id}
&client_secret={client_secret}

토큰 정보 요약​

항목값
Access Token 유효기간1시간 (3,600초)
Refresh Token 유효기간90일 (7,776,000초)
Authorization Code 유효기간10분 (600초)
Token TypeBearer
Issuerhttps://openapi.gency.ai

서버 메타데이터​

OAuth2 서버 설정 정보는 아래 엔드포인트에서 확인할 수 있습니다.

GET https://openapi.gency.ai/.well-known/oauth-authorization-server