認証バックエンド管理フロー
目的: プライベート バックエンド クライアントを使用して auth.inbox-manager.com に対して認証し、特権ユーザー/アカウント/メンバーシップの操作を実行します。
境界メモ:
- このガイドは
auth.inbox-manager.comおよびapi.inbox-manager.comを対象としています。 - これらのエンドポイントは
api.inbox-manager.comOpenAPI の外部にあります。
視聴者ルール
- このクライアントは
api.inbox-manager.com/auth.inbox-manager.comAPI を呼び出すためのクライアントです。 - トークンの対象者は
https://api.inbox-manager.comである必要があります。 - パブリック アプリ クライアントはオーディエンス
https://api.inbox-manager.comとは分離されたままになります。
UI フロー
- ブラウザは使用しません。
- バックエンド サービスは、クライアントの資格情報を介して M2M トークンを作成します。
- バックエンドはユーザー/アカウント/メンバー管理 API を実行します。
- バックエンドは内部ジョブ/ログ システムに結果を記録します。
クライアント ライブラリ フロー
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/usersPOST /api/accounts/:account_id/accountsPOST /api/accounts/:account_id/membersPATCH /api/accounts/:account_id/members/:member_idDELETE /api/accounts/:account_id/members/:member_idPATCH /api/accounts/:account_idDELETE /api/accounts/:account_idDELETE /api/users/:user_id
検証スクリプト
scripts/auth_backend_admin_flow.sh