IM
JA
ドキュメントホーム
メニュー
ガイド

認証バックエンド管理フロー

プライベート バックエンド クライアントを使用して「auth.inbox-manager.com」への認証を行い、特権ユーザー/アカウント/メンバーシップ操作を実行します。

inbox-manager client-flow

認証バックエンド管理フロー

目的: プライベート バックエンド クライアントを使用して auth.inbox-manager.com に対して認証し、特権ユーザー/アカウント/メンバーシップの操作を実行します。

境界メモ:

  • このガイドは auth.inbox-manager.com および api.inbox-manager.com を対象としています。
  • これらのエンドポイントは api.inbox-manager.com OpenAPI の外部にあります。

視聴者ルール

  • このクライアントは api.inbox-manager.com / auth.inbox-manager.com API を呼び出すためのクライアントです。
  • トークンの対象者は https://api.inbox-manager.com である必要があります。
  • パブリック アプリ クライアントはオーディエンス https://api.inbox-manager.com とは分離されたままになります。

UI フロー

  1. ブラウザは使用しません。
  2. バックエンド サービスは、クライアントの資格情報を介して M2M トークンを作成します。
  3. バックエンドはユーザー/アカウント/メンバー管理 API を実行します。
  4. バックエンドは内部ジョブ/ログ システムに結果を記録します。

クライアント ライブラリ フロー

const auth = new OAuthClient({
  tokenUrl: "https://auth.inbox-manager.com/oauth2/token",
  clientId: process.env.AUTH_BACKEND_ADMIN_CLIENT_ID!,
  clientSecret: process.env.AUTH_BACKEND_ADMIN_CLIENT_SECRET!,
});

const token = await auth.clientCredentials({
  audience: "https://api.inbox-manager.com",
});

const authApi = new InboxManagerAdminClient({
  baseUrl: "https://api.inbox-manager.com",
  bearerToken: token.access_token,
});

const user = await authApi.createApplicationUser(appId, { status: "active" });
const account = await authApi.createChildAccount(parentAccountId, {
  name: "ops-provisioned",
});
const membership = await authApi.addAccountMember(
  account.id,
  user.id,
  "viewer",
);

HTTP/カールフロー

curl -sS -X POST "https://auth.inbox-manager.com/oauth2/token" \
  -H "content-type: application/json" \
  --data "{
    \"grant_type\": \"client_credentials\",
    \"client_id\": \"${AUTH_BACKEND_ADMIN_CLIENT_ID}\",
    \"client_secret\": \"${AUTH_BACKEND_ADMIN_CLIENT_SECRET}\",
    \"audience\": \"https://api.inbox-manager.com\"
  }"

次に、次のように呼び出します。

  • POST /api/applications/:application_id/users
  • POST /api/accounts/:account_id/accounts
  • POST /api/accounts/:account_id/members
  • PATCH /api/accounts/:account_id/members/:member_id
  • DELETE /api/accounts/:account_id/members/:member_id
  • PATCH /api/accounts/:account_id
  • DELETE /api/accounts/:account_id
  • DELETE /api/users/:user_id

検証スクリプト

  • scripts/auth_backend_admin_flow.sh