> ## Documentation Index
> Fetch the complete documentation index at: https://translations.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Auth0 Dashboard または Management API を使用して、組織にメンバーを直接割り当てる方法を学びます。

# 組織にメンバーを割り当てる

export const AuthCodeGroup = ({children, dropdown}) => {
  const [processedChildren, setProcessedChildren] = useState(children);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      unsubscribe = window.autorun(() => {
        const processChildren = node => {
          if (typeof node === "string") {
            let processedNode = node;
            for (const [key, value] of window.rootStore.variableStore.values.entries()) {
              const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
              processedNode = processedNode.replaceAll(new RegExp(escapedKey, "g"), value);
            }
            return processedNode;
          } else if (Array.isArray(node)) {
            return node.map(processChildren);
          } else if (node && node.props && node.props.children) {
            return {
              ...node,
              props: {
                ...node.props,
                children: processChildren(node.props.children)
              }
            };
          }
          return node;
        };
        setProcessedChildren(processChildren(children));
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  return <CodeGroup dropdown={dropdown}>{processedChildren}</CodeGroup>;
};

[組織](/docs/ja-jp/manage-users/organizations/organizations-overview) にメンバーを割り当てるには、事前にテナント内で[ユーザーを作成しておく](/docs/ja-jp/manage-users/user-accounts/create-users)必要があります。ユーザーが見つからない場合は、代わりに[招待する](/docs/ja-jp/manage-users/organizations/configure-organizations/invite-members)こともできます。

メンバーを直接管理するには、<Tooltip tip="Auth0 Dashboard: サービスを設定するための Auth0 の主要プロダクト。" cta="用語集を表示" href="/docs/ja-jp/glossary?term=Auth0+Dashboard">Auth0 Dashboard</Tooltip> または <Tooltip tip="Auth0 Dashboard: サービスを設定するための Auth0 の主要プロダクト。" cta="用語集を表示" href="/docs/ja-jp/glossary?term=Management+API">Management API</Tooltip> のいずれかを使用できます。

<div id="auth0-dashboard">
  ## Auth0 Dashboard
</div>

Auth0 Dashboard でメンバーを割り当てるには、次の手順を実行します。

1. [Auth0 Dashboard > Organizations](https://manage.auth0.com/#/organizations) に移動し、メンバーシップを設定する 組織 を選択します。
2. **Members** ビューを選択し、**Add members**、**Add Users** の順に選択します。
3. 組織 のメンバーとして割り当てるユーザー名を入力し、**Add user(s) to organization** を選択します。

<div id="management-api">
  ## Management API
</div>

Management API を使用してメンバーを割り当てるには:

`Create Organization Members` エンドポイントに `POST` リクエストを送信します。`ORG_ID`、`MGMT_API_ACCESS_TOKEN`、`USER_ID` の各プレースホルダー値は、それぞれ組織ID、Management API <Tooltip tip="Access Token: API へのアクセスに使用される、opaque な文字列または JWT 形式の Authorization 認証情報。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=Access+Token">Access Token</Tooltip>、および user ID に必ず置き換えてください。

<AuthCodeGroup>
  ```bash cURL lines theme={null}
  curl --request POST \
    --url https://{yourDomain}/api/v2/organizations/ORG_ID/members \
    --header 'authorization: Bearer MGMT_API_ACCESS_TOKEN' \
    --header 'cache-control: no-cache' \
    --header 'content-type: application/json' \
    --data '{ "members": [ "USER_ID", "USER_ID", "USER_ID" ] }'
  ```

  ```csharp C# lines theme={null}
  var client = new RestClient("https://{yourDomain}/api/v2/organizations/ORG_ID/members");
  var request = new RestRequest(Method.POST);
  request.AddHeader("content-type", "application/json");
  request.AddHeader("authorization", "Bearer MGMT_API_ACCESS_TOKEN");
  request.AddHeader("cache-control", "no-cache");
  request.AddParameter("application/json", "{ \"members\": [ \"USER_ID\", \"USER_ID\", \"USER_ID\" ] }", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  ```

  ```go Go lines expandable theme={null}
  package main

  import (
  	"fmt"
  	"strings"
  	"net/http"
  	"io/ioutil"
  )

  func main() {

  	url := "https://{yourDomain}/api/v2/organizations/ORG_ID/members"

  	payload := strings.NewReader("{ \"members\": [ \"USER_ID\", \"USER_ID\", \"USER_ID\" ] }")

  	req, _ := http.NewRequest("POST", url, payload)

  	req.Header.Add("content-type", "application/json")
  	req.Header.Add("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
  	req.Header.Add("cache-control", "no-cache")

  	res, _ := http.DefaultClient.Do(req)

  	defer res.Body.Close()
  	body, _ := ioutil.ReadAll(res.Body)

  	fmt.Println(res)
  	fmt.Println(string(body))

  }
  ```

  ```java Java lines theme={null}
  HttpResponse<String> response = Unirest.post("https://{yourDomain}/api/v2/organizations/ORG_ID/members")
    .header("content-type", "application/json")
    .header("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
    .header("cache-control", "no-cache")
    .body("{ \"members\": [ \"USER_ID\", \"USER_ID\", \"USER_ID\" ] }")
    .asString();
  ```

  ```javascript Node.JS lines theme={null}
  var axios = require("axios").default;

  var options = {
    method: 'POST',
    url: 'https://{yourDomain}/api/v2/organizations/ORG_ID/members',
    headers: {
      'content-type': 'application/json',
      authorization: 'Bearer MGMT_API_ACCESS_TOKEN',
      'cache-control': 'no-cache'
    },
    data: {members: ['USER_ID', 'USER_ID', 'USER_ID']}
  };

  axios.request(options).then(function (response) {
    console.log(response.data);
  }).catch(function (error) {
    console.error(error);
  });
  ```

  ```php PHP lines expandable theme={null}
  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://{yourDomain}/api/v2/organizations/ORG_ID/members",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "{ \"members\": [ \"USER_ID\", \"USER_ID\", \"USER_ID\" ] }",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer MGMT_API_ACCESS_TOKEN",
      "cache-control: no-cache",
      "content-type: application/json"
    ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
  ```

  ```python Python lines theme={null}
  import http.client

  conn = http.client.HTTPSConnection("{yourDomain}")

  payload = "{ \"members\": [ \"USER_ID\", \"USER_ID\", \"USER_ID\" ] }"

  headers = {
      'content-type': "application/json",
      'authorization': "Bearer MGMT_API_ACCESS_TOKEN",
      'cache-control': "no-cache"
      }

  conn.request("POST", "/api/v2/organizations/ORG_ID/members", payload, headers)

  res = conn.getresponse()
  data = res.read()

  print(data.decode("utf-8"))
  ```

  ```ruby Ruby lines theme={null}
  require 'uri'
  require 'net/http'
  require 'openssl'

  url = URI("https://{yourDomain}/api/v2/organizations/ORG_ID/members")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER

  request = Net::HTTP::Post.new(url)
  request["content-type"] = 'application/json'
  request["authorization"] = 'Bearer MGMT_API_ACCESS_TOKEN'
  request["cache-control"] = 'no-cache'
  request.body = "{ \"members\": [ \"USER_ID\", \"USER_ID\", \"USER_ID\" ] }"

  response = http.request(request)
  puts response.read_body
  ```
</AuthCodeGroup>

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  **Auth0 ドメインを確認する**

  Auth0 ドメインは、テナント名、リージョンのサブドメイン (テナントが US リージョンにあり、2020 年 6 月以前に作成されている場合を除く) 、および `.auth0.com` を組み合わせたものです。たとえば、テナント名が `travel0` の場合、Auth0 ドメイン名は `travel0.us.auth0.com` になります。 (テナントが US にあり、2020 年 6 月以前に作成されている場合、ドメイン名は `https://travel0.auth0.com` になります。)

  カスタムドメインを使用している場合は、ここにそのカスタムドメイン名を指定します。
</Callout>

| 値                       | 説明                                                                                                                                                  |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ORG_ID`                | メンバーシップを割り当てる 組織 の ID。                                                                                                                              |
| `MGMT_API_ACCESS_TOKEN` | スコープ `create:organization_members` を持つ [Access Token for the Management API](/docs/ja-jp/secure/tokens/access-tokens/management-api-access-tokens)。 |
| `USER_ID`               | 指定した 組織 に割り当てるユーザーの ID。1 回のリクエストで、組織 ごとに最大 10 人のメンバーを送信できます。                                                                                        |

<div id="response-status-codes">
  ### レスポンスのステータスコード
</div>

想定されるレスポンスのステータスコードは次のとおりです。

| ステータスコード | エラーコード                 | メッセージ                                                                                 | 原因                                                   |
| -------- | ---------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `204`    |                        | メンバーが 組織 に正常に追加されました。                                                                 |                                                      |
| `400`    | `invalid_body`         | 無効なリクエスト本文です。メッセージは原因に応じて異なります。                                                       | リクエストのペイロードが無効です。                                    |
| `400`    | `invalid_query_string` | 無効なリクエストクエリ文字列です。メッセージは原因に応じて異なります。                                                   | クエリ文字列が無効です。                                         |
| `401`    |                        | 無効なトークンです。                                                                            |                                                      |
| `401`    |                        | JSON Web トークンのバリデーションで無効な署名を受信しました。                                                   |                                                      |
| `401`    |                        | クライアントはグローバルではありません。                                                                  |                                                      |
| `403`    | `insufficient_scope`   | スコープが不十分です。必要なスコープのいずれか: `create:organization_members`。                               | 提供されたベアラートークンのスコープでは許可されていないフィールドの読み取りまたは書き込みを試みました。 |
| `429`    |                        | リクエストが多すぎます。X-RateLimit-Limit、X-RateLimit-Remaining、X-RateLimit-Reset のヘッダーを確認してください。 |                                                      |
