AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。

agentengine service-account create

サービス アカウントの作成

サービスアカウントを作成し、最初のクライアントシークレットを発行します。

シークレットは一度しか表示されません。すぐに保存してください。

書き込み /API/v1/oauth/token でクライアントIDとシークレットを1時間有効なアクセストークンと交換します。そのトークンは、サービスアカウント認証が明示的に有効になっているエンドポイントとなる接続されたデバイスにのみ送信し、割り当てられたロールで許可されている場合にのみ送信してください。

curl --fail-with-body --silent --show-error \ --user '<client-id>' \ --data grant_type=client_credentials \ '<base-url>/api/v1/oauth/token' | \jq -er '"Authorization: Bearer " + .access_token' | \curl --fail-with-body --silent --show-error \ --header @- \ '<base-url>/api/v1/<service-account-enabled-resource>'

プロジェクトのロールはPROJECT_OWNERとPROJECT_READ_ONLY、組織のロールはORG_OWNER、ORG_GROUP_CREATOR、ORG_READ_ONLYです。ORG_OWNERは、組織でオーナーロールが有効になっている場合にのみ受け入れられます。それ以外の場合、サーバーは拒否します。ListおよびGetは、アカウントのAtlasロールを表示します。

サービスアカウントを作成すると、ペアとなるAtlasサービスアカウントも作成できます。これには、組織またはプロジェクトでAtlasサービスアカウントのペアリングが有効になっている必要があります。無効になっている場合、コマンドはペアリングされたアカウントについて説明し、ターミナルでは有効にする前に確認を求めます。例として、スクリプトなどでプロンプトなしで有効にするには、--enable-atlas-pairingを渡します。拒否した場合、またはターミナルなしでフラグを省略した場合は、何も作成されません。ペアとなるAtlasサービスアカウントが作成されると、そのIDが結果とともに表示されます。

例:

agentengine service-account create ci-pipeline --role PROJECT_OWNERagentengine service-account create audit-reader --org-id <org-id> --role ORG_READ_ONLY
agentengine service-account create <name> --role <role> [flags]
--base-url string Platform base URL --context string Named context to target (see 'agentengine context list') --description string Human-readable description --enable-atlas-pairing Turn on Atlas service account pairing for the organization or project if it is off, without a prompt. The notice goes to stderr-h, --help help for create --ip-access-list strings IPs or CIDRs allowed to use the credential (default: unrestricted) --json Output the created service account as JSON --org-id string Organization scope for the service account --project-id string Project scope for the service account --role string Role granted to the service account (project: PROJECT_OWNER, PROJECT_READ_ONLY; organization: ORG_OWNER, ORG_GROUP_CREATOR, ORG_READ_ONLY) --secret-expires-in duration Secret lifetime as a whole number of hours, e.g. 720h (default: server default of 2160h)
--log-file string override log file path --log-level string file log verbosity (error|warn|info|debug) (default "info") --no-log disable file logging-q, --quiet silence stderr below error-v, --verbose count raise stderr verbosity (-v info, -vv debug)
このページを評価