> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.com/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/connections/database)、[ソーシャル接続](/docs/ja-jp/connections/identity-providers-social)や[エンタープライズ接続](/docs/ja-jp/connections/identity-providers-enterprise)が含まれます。

## 組織のプロパティ

組織を使う場合、接続によっては以下のようなプロパティを追加で構成することができます。

| **プロパティ**                                     | **接続の種類**    | **説明**                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| :-------------------------------------------- | :----------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Membership On Authentication（認証時のメンバーシップ）     | 全種類の接続       | 有効にすると、指定の接続を使用した初回の認証でエンドユーザーに組織のメンバーシップを自動的に割り当てます。<br /><br />これは、その接続で認証可能なすべてのユーザーが組織のメンバーになる場合に便利です。                                                                                                                                                                                                                                                                                                                                                                   |
| Organization Signup（組織のサインアップ）                | データベース接続のみ   | エンドユーザーがログインプロンプトでサインアップリンクを使用して、組織のメンバーシップも獲得できるかを決定します。これ使用するには、［Membership On Authentication（認証時のメンバーシップ）］も有効にする必要があります。<br /><br />以下のように、ユーザーの自主的な組織への参加が必要な場合に使用します。<ul><li>ワークスペースなど、組織が自由参加のユーザー集団をモデルにしている</li><li>B2B2C（ビジネス対ビジネス対消費者）のユースケースで、ユーザーが自由にアカウントにサインアップできる</li></ul>                                                                                                                                                                                   |
| Display connection as a button（接続をボタンとして表示する） | エンタープライズ接続のみ | この任意のプロパティは、組織のログインプロンプトで特定の接続をオプションとして表示するかを決定します。<br /><br />**注意**：このオプションが接続に無効な場合でも、接続パラメーターを認可要求に含めて直接送信すると、エンドユーザーはその接続で認証し、組織のアプリケーションにログインできます。また、[ホーム領域検出を使用したIdentifier First](/docs/ja-jp/authenticate/login/auth0-universal-login/identifier-first")認証プロファイルを[［Prompt for Credentials（資格情報を求める）］](/docs/ja-jp/manage-users/organizations/login-flows-for-organizations#configure-the-login-flow-for-your-application)組織ログインフローと組み合わせて使っている場合も、ユーザーはその接続で認証できます。 |

<Warning>
  エンドユーザーは特定の組織に関連したアプリケーションにのみ、その組織に有効な接続を使ってログインできます。
</Warning>

## 組織の接続を構成する

組織の接続は<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-jp/glossary?term=auth0-dashboard" tip="Auth0 Dashboard: サービスを構成するためのAuth0の主製品。" cta="用語集の表示">Auth0 Dashboard</Tooltip>または<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-jp/glossary?term=management-api" tip="Management API: 顧客が管理タスクを実行できるようにするための製品。" cta="用語集の表示">Management API</Tooltip>を使って構成することができます。

<Tabs>
  <Tab title="Auth0 Dashboard">
    #### Auth0 Dashboard

    Auth0 Dashboardを使って接続を有効にするには以下を行います。

    1. [［Auth0 Dashboard］ > ［Organizations］](https://manage.auth0.com/#/organizations)に移動して、接続を構成したいOrganizationを選択します。

    2. **［Connections（接続）］** ビューを選択してから、**［Enable Connections（接続の有効化）］** を選択します。

    3. 有効にしたい接続を選んで、**［Enable Connection（接続の有効化）］** を選択します。

    4. ［Authentication（認証）］セクションの **［Membership On Authentication（認証時のメンバーシップ）］**］、メンバーシップの自動付与を有効または無効に設定します。有効にすると、その接続を使ってログインするユーザーがすべてOrganizationのメンバーとして自動的に追加されます。

    5. **データベース接続のみ**：［Organization Signup（Organizationのサインアップ）］セクションで、ユーザーの自主的なサインアップを有効または無効に設定します。有効にすると、ユーザーはログインプロンプトのサインアップリンクを使って自分のアカウントを作成し、自動的にOrganizationのメンバーシップを取得できるようになります。

       * **注**：これを有効にするには、まず **［Membership on Authentication（認証時のメンバーシップ）］** を有効にする必要があります。

    6. **エンタープライズ接続のみ**：その接続がOrganizationのログインプロンプトでオプションとして表示されるように、接続ボタンセクションで任意の **［Display connection as a button（接続をボタンで表示）］** プロパティを有効に設定します。

           <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
             Organization内の有効な接続がすべてエンタープライズ接続で、すべての接続が非表示の場合、ユーザーがアプリケーションにアクセスすると、Auth0から「`Message: no connections enabled for the organization are visible`（メッセージ：組織に対して有効化された接続はすべて非表示です）」というエラーが返されます。
           </Callout>

    7. **［Save（保存）］** を選択します。
  </Tab>

  <Tab title="Management API">
    #### Management API

    Management APIを使って接続を有効にするには以下を行います。

    `Create Organization Connections`エンドポイントに`POST`呼び出しを行います。必ず、以下のプレースホルダーの値を適切な情報で更新してください。

    * `{orgId}`をOrganization IDに置き換えます。
    * `{mgmtApiAccessToken}`をManagement APIのアクセストークンに置き換えます。
    * `{connectionId}`を特定の接続IDに置き換えます。
    * ［Membership on Authentication（認証時のメンバーシップ）］の設定に合わせて、`{assignMembershipOption}`を`true`または`false`に置き換えます。
    * **データベース接続のみ** ：サインアップの設定に合わせて、`{isSignupEnabled}`を`true`または`false`に置き換えます。
    * **エンタープライズ接続のみ** ：接続ボタンの設定に合わせて、`{showAsButtonOption}`を`true`または`false`に置き換えます。

    <AuthCodeGroup>
      ```bash cURL lines theme={null}
      curl --request POST \
        --url https://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections \
        --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
        --header 'cache-control: no-cache' \
        --header 'content-type: application/json' \
        --data '{ "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}","is_signup_enabled","{isSignupEnabled}", "show_as_button": "{showAsButtonOption}" }'
      ```

      ```csharp C# lines theme={null}
      var client = new RestClient("https://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections");
      var request = new RestRequest(Method.POST);
      request.AddHeader("content-type", "application/json");
      request.AddHeader("authorization", "Bearer {yourMgmtApiAccessToken}");
      request.AddHeader("cache-control", "no-cache");
      request.AddParameter("application/json", "{ \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\",\"is_signup_enabled\",\"{isSignupEnabled}\", \"show_as_button\": \"{showAsButtonOption}\" }", 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://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections"

      	payload := strings.NewReader("{ \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\",\"is_signup_enabled\",\"{isSignupEnabled}\", \"show_as_button\": \"{showAsButtonOption}\" }")

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

      	req.Header.Add("content-type", "application/json")
      	req.Header.Add("authorization", "Bearer {yourMgmtApiAccessToken}")
      	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://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections")
        .header("content-type", "application/json")
        .header("authorization", "Bearer {yourMgmtApiAccessToken}")
        .header("cache-control", "no-cache")
        .body("{ \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\",\"is_signup_enabled\",\"{isSignupEnabled}\", \"show_as_button\": \"{showAsButtonOption}\" }")
        .asString();
      ```

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

      var options = {
        method: 'POST',
        url: 'https://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections',
        headers: {
          'content-type': 'application/json',
          authorization: 'Bearer {yourMgmtApiAccessToken}',
          'cache-control': 'no-cache'
        },
        data: '{ "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}","is_signup_enabled","{isSignupEnabled}", "show_as_button": "{showAsButtonOption}" }'
      };

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

      ```objc Obj-C lines expandable theme={null}
      #import <Foundation/Foundation.h>

      NSDictionary *headers = @{ @"content-type": @"application/json",
                                 @"authorization": @"Bearer {yourMgmtApiAccessToken}",
                                 @"cache-control": @"no-cache" };

      NSData *postData = [[NSData alloc] initWithData:[@"{ "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}","is_signup_enabled","{isSignupEnabled}", "show_as_button": "{showAsButtonOption}" }" dataUsingEncoding:NSUTF8StringEncoding]];

      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections"]
                                                             cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                         timeoutInterval:10.0];
      [request setHTTPMethod:@"POST"];
      [request setAllHTTPHeaderFields:headers];
      [request setHTTPBody:postData];

      NSURLSession *session = [NSURLSession sharedSession];
      NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                                  completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                      if (error) {
                                                          NSLog(@"%@", error);
                                                      } else {
                                                          NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                          NSLog(@"%@", httpResponse);
                                                      }
                                                  }];
      [dataTask resume];
      ```

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

      curl_setopt_array($curl, [
        CURLOPT_URL => "https://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => "{ \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\",\"is_signup_enabled\",\"{isSignupEnabled}\", \"show_as_button\": \"{showAsButtonOption}\" }",
        CURLOPT_HTTPHEADER => [
          "authorization: Bearer {yourMgmtApiAccessToken}",
          "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("")

      payload = "{ \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\",\"is_signup_enabled\",\"{isSignupEnabled}\", \"show_as_button\": \"{showAsButtonOption}\" }"

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

      conn.request("POST", "%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections", 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://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections")

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

      request = Net::HTTP::Post.new(url)
      request["content-type"] = 'application/json'
      request["authorization"] = 'Bearer {yourMgmtApiAccessToken}'
      request["cache-control"] = 'no-cache'
      request.body = "{ \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\",\"is_signup_enabled\",\"{isSignupEnabled}\", \"show_as_button\": \"{showAsButtonOption}\" }"

      response = http.request(request)
      puts response.read_body
      ```

      ```swift Swift lines expandable theme={null}
      import Foundation

      let headers = [
        "content-type": "application/json",
        "authorization": "Bearer {yourMgmtApiAccessToken}",
        "cache-control": "no-cache"
      ]

      let postData = NSData(data: "{ "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}","is_signup_enabled","{isSignupEnabled}", "show_as_button": "{showAsButtonOption}" }".data(using: String.Encoding.utf8)!)

      let request = NSMutableURLRequest(url: NSURL(string: "https://%7ByourAuth0Domain%7D/api/v2/organizations/%7BorgId%7D/enabled_connections")! as URL,
                                              cachePolicy: .useProtocolCachePolicy,
                                          timeoutInterval: 10.0)
      request.httpMethod = "POST"
      request.allHTTPHeaderFields = headers
      request.httpBody = postData as Data

      let session = URLSession.shared
      let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
        if (error != nil) {
          print(error)
        } else {
          let httpResponse = response as? HTTPURLResponse
          print(httpResponse)
        }
      })

      dataTask.resume()
      ```
    </AuthCodeGroup>

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      **Auth0ドメインを見つける**

      テナント名がAuth0ドメインである場合は、地域のサブドメイン（テナントが米国地域にあり、2020年6月より前に作成された場合を除く）の後に「`.auth0.com`」が続きます。たとえば、テナント名が「`travel0`」の場合、Auth0のドメイン名は「`travel0.us.auth0.com`」になります。（テナントが米国内にあって、2020年6月よりも前に作成された場合、ドメイン名は「`https://travel0.auth0.com`」になります。）

      カスタムドメインを使用している場合には、これがカスタムドメイン名になります。
    </Callout>

    | **値**                      | **説明**                                                                                                                                                                                            |
    | :------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    | `{orgId}`                  | 接続を有効にしたい組織のID。                                                                                                                                                                                   |
    | `{mgmtApiAccessToken}`     | `create:organization_connections`のスコープを持つ［Management APIアクセストークン］（/tokens/management-api-access-tokens）                                                                                           |
    | `{connectionId}`           | 特定の組織に有効化したい接続のID。                                                                                                                                                                                |
    | `{assignMembershipOption}` | この接続を使ってログインするユーザーに対して、組織のメンバーシップを自動的に付与したいかを指定する。`true`に設定すると、ユーザーに対して自動的にメンバーシップが付与されます。`false`に設定すると、メンバーシップは自動的に付与されません。                                                                      |
    | `{isSignupEnabled}`        | ユーザーがログインプロンプトでセルフサービスのサインアップリンクにアクセスできるかどうかを指定します。`true`に設定すると、プロンプトにサインアップリンクが表示されます。`false`に設定すると、リンクは表示されません。<br /><br />**注**：このオプションを有効にするには、`{assignMembershipOption}`も`true`に設定する必要があります。 |
    | `{showAsButtonOption}`     | 組織のログインプロンプトに特定のエンタープライズ接続をオプションとして表示したいかを指定します。`true`に設定すると、プロンプトに接続がボタンとして表示されます。`false`に設定すると、プロンプトに接続は表示されません。                                                                                |

    ##### 応答ステータスコード

    可能性のある応答ステータスコードは以下のとおりです。

    | **ステータス コード** | **エラーコード**           | **メッセージ**                                                                        | **原因**                                           |
    | :------------ | :------------------- | :------------------------------------------------------------------------------- | :----------------------------------------------- |
    | `201`         |                      | 接続が組織に正常に追加されました。                                                                |                                                  |
    | `401`         |                      | 無効なトークンです。                                                                       |                                                  |
    | `401`         |                      | JSON Web Tokenの検証に無効な署名を受信しました。                                                  |                                                  |
    | `401`         |                      | クライアントがグローバルではありません。                                                             |                                                  |
    | `403`         | `insufficient_scope` | スコープが不足しています。`create:organizations_connections`のいずれかが予期されています。                   | 提供されたベアラートークンのスコープでは許可されないフィールドの読み込み/書き込みが試行された。 |
    | `429`         |                      | 要求が多すぎます。X-RateLimit-Limit、X-RateLimit-Remaining、X-RateLimit-Resetヘッダーを確認してください。 |                                                  |
  </Tab>
</Tabs>
