メインコンテンツまでスキップ

認証 (OAuth)

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