> ## 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.

> authorizeリクエスト時にAuth0アプリケーションからクエリーパラメーターを渡し、ソーシャルまたはエンタープライズIDプロバイダーのログイン動作を制御する方法について説明します。

# IDプロバイダーへパラメーターを渡す

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>;
};

export const AuthCodeBlock = ({filename, icon, language, highlight, children}) => {
  const [displayText, setDisplayText] = useState(children);
  const [copyText, setCopyText] = useState(children);
  const wrapperRef = React.useRef(null);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      if (!window.autorun || !window.rootStore) {
        return;
      }
      unsubscribe = window.autorun(() => {
        let processedChildrenForDisplay = children;
        let processedChildrenForCopy = children;
        for (const [key, value] of window.rootStore.variableStore.values.entries()) {
          const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
          let displayValue = value;
          if (key === "{yourClientSecret}" && value !== "{yourClientSecret}") {
            displayValue = value.substring(0, 3) + "*****マスク済み*****";
          }
          processedChildrenForDisplay = processedChildrenForDisplay.replaceAll(new RegExp(escapedKey, "g"), displayValue);
          processedChildrenForCopy = processedChildrenForCopy.replaceAll(new RegExp(escapedKey, "g"), value);
        }
        setDisplayText(processedChildrenForDisplay);
        setCopyText(processedChildrenForCopy);
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  useEffect(() => {
    if (!wrapperRef.current) return;
    const originalWriteText = navigator.clipboard.writeText.bind(navigator.clipboard);
    let isOverriding = false;
    const handleClick = e => {
      const button = e.target.closest('[data-testid="copy-code-button"]');
      if (!button || !wrapperRef.current.contains(button)) return;
      isOverriding = true;
      navigator.clipboard.writeText = text => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
          return originalWriteText(copyText);
        }
        return originalWriteText(text);
      };
      setTimeout(() => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
        }
      }, 100);
    };
    const wrapper = wrapperRef.current;
    wrapper.addEventListener('click', handleClick, true);
    return () => {
      wrapper.removeEventListener('click', handleClick, true);
      if (navigator.clipboard.writeText !== originalWriteText) {
        navigator.clipboard.writeText = originalWriteText;
      }
    };
  }, [copyText]);
  return <div ref={wrapperRef}>
      <CodeBlock filename={filename} icon={icon} language={language} lines highlight={highlight}>
        {displayText}
      </CodeBlock>
    </div>;
};

認証時に、<Tooltip tip="IDプロバイダー（IdP）：デジタルアイデンティティを保存・管理するサービス。" cta="用語集を表示" href="/ja/docs/glossary?term=Identity+Provider">IDプロバイダー</Tooltip> (IdP) にプロバイダー固有のパラメーターを渡すことができます。値は、接続ごとに固定することも、ユーザーごとに動的に設定することもできます。

<div id="limitations">
  ## 制限事項
</div>

この構成では、次の制限事項に注意してください。

* [有効な OAuth 2.0/OIDC パラメーター](http://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint)のみ受け付けられます。
* すべての IdP がアップストリームパラメーターをサポートしているわけではありません。実装を進める前に、対象の IdP に確認してください。
* <Tooltip tip="Security Assertion Markup Language (SAML): パスワードなしで2者間の認証情報のやり取りを可能にする標準化されたプロトコル。" cta="用語集を表示" href="/ja/docs/glossary?term=SAML">SAML</Tooltip> IdP はアップストリームパラメーターをサポートしていません。

<div id="static-parameters">
  ## 静的パラメーター
</div>

静的パラメーターを使用すると、ユーザーのログイン時に標準的なパラメーターのセットを IdP に送信するよう接続を設定できます。

静的パラメーターを設定するには、Auth0 の <Tooltip tip="Management API: 管理タスクを実行するための製品です。" cta="用語集を見る" href="/ja/docs/glossary?term=Management+API">Management API</Tooltip> の [接続を作成する](https://auth0.com/docs/api/management/v2/#!/Connections/post_connections) エンドポイントまたは [接続を更新する](https://auth0.com/docs/api/management/v2/#!/Connections/patch_connections_by_id) エンドポイントを呼び出し、IdP に送信するパラメーターを含む `upstream_params` オブジェクトを `options` オブジェクト内で渡します。

<div id="example-wordpress">
  ### 例: WordPress
</div>

WordPress では、<Tooltip tip="OAuth 2.0: 認可プロトコルとワークフローを定義する認可フレームワーク。" cta="用語集を表示" href="/ja/docs/glossary?term=OAuth+2.0">OAuth 2.0</Tooltip> の認可エンドポイントに任意の `blog` パラメーターを渡すことで、ユーザーのログイン時に指定したブログへのアクセスを自動的に要求できます。詳しくは、[WordPress の OAuth 2.0 ドキュメント](https://developer.wordpress.com/docs/oauth2/)を参照してください。

この例を実行するには、有効な [WordPress Social 接続](https://marketplace.auth0.com/integrations/wordpress-social-connection) が必要です。

<div id="get-the-connection">
  #### 接続を取得する
</div>

Management API の [Get a connection](https://auth0.com/docs/api/management/v2#!/Connections/get_connections_by_id) エンドポイントを呼び出し、`options` オブジェクトの現在の値を取得します。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID} \
    --header 'authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}' \
    --header 'content-type: application/json'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID}");
  var request = new RestRequest(Method.GET);
  request.AddHeader("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}");
  request.AddHeader("content-type", "application/json");
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID}"

  	req, _ := http.NewRequest("GET", url, nil)

  	req.Header.Add("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
  	req.Header.Add("content-type", "application/json")

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

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

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

  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.get("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID}")
    .header("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
    .header("content-type", "application/json")
    .asString();
  ```

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

  var options = {
    method: 'GET',
    url: 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID}',
    headers: {
      authorization: 'Bearer {YOUR_MANAGEMENT_API_TOKEN}',
      'content-type': 'application/json'
    }
  };

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

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

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      "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 theme={null}
  import http.client

  conn = http.client.HTTPSConnection("")

  headers = {
      'authorization': "Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      'content-type': "application/json"
      }

  conn.request("GET", "/{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID}", headers=headers)

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

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

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

  url = URI("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_WORDPRESS_CONNECTION_ID}")

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

  request = Net::HTTP::Get.new(url)
  request["authorization"] = 'Bearer {YOUR_MANAGEMENT_API_TOKEN}'
  request["content-type"] = 'application/json'

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

`options` オブジェクトは次のようになります。

```json lines theme={null}
{
  "options": {
    "client_id": "", 
    "profile": true, 
    "scope": ["profile"]
  }
}
```

<div id="update-the-connection-static">
  #### 接続を更新する (静的)
</div>

既存の`options`オブジェクトをコピーし、属性として`blog`フィールドを含む`upstream_params`オブジェクトを追加します。

```json lines theme={null}
{
  "options": {
    "client_id": "", 
    "profile": true, 
    "scope": ["profile"],
    "upstream_params": {
      "blog": {"value":"myblog.wordpress.com"}
    }
  }
}
```

リクエスト本文に `options` オブジェクトを含めて、Management API の [Update a connection](https://auth0.com/docs/api/management/v2/#!/Connections/patch_connections_by_id) エンドポイントを呼び出します。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request PATCH \
    --url 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D' \
    --header 'authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}' \
    --header 'content-type: application/json' \
    --data '{"options":{"client_id":"","profile":true,"scope":["profile"],"upstream_params":{"blog":{"value":"myblog.wordpress.com"}}}}'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D");
  var request = new RestRequest(Method.PATCH);
  request.AddHeader("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}");
  request.AddHeader("content-type", "application/json");
  request.AddParameter("application/json", "{"options":{"client_id":"","profile":true,"scope":["profile"],"upstream_params":{"blog":{"value":"myblog.wordpress.com"}}}}", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D"

  	payload := strings.NewReader("{"options":{"client_id":"","profile":true,"scope":["profile"],"upstream_params":{"blog":{"value":"myblog.wordpress.com"}}}}")

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

  	req.Header.Add("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
  	req.Header.Add("content-type", "application/json")

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

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

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

  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.patch("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D")
    .header("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
    .header("content-type", "application/json")
    .body("{"options":{"client_id":"","profile":true,"scope":["profile"],"upstream_params":{"blog":{"value":"myblog.wordpress.com"}}}}")
    .asString();
  ```

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

  var options = {
    method: 'PATCH',
    url: 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D',
    headers: {
      authorization: 'Bearer {YOUR_MANAGEMENT_API_TOKEN}',
      'content-type': 'application/json'
    },
    data: {
      options: {
        client_id: '',
        profile: true,
        scope: ['profile'],
        upstream_params: {blog: {value: 'myblog.wordpress.com'}}
      }
    }
  };

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

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

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PATCH",
    CURLOPT_POSTFIELDS => "{"options":{"client_id":"","profile":true,"scope":["profile"],"upstream_params":{"blog":{"value":"myblog.wordpress.com"}}}}",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      "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 theme={null}
  import http.client

  conn = http.client.HTTPSConnection("")

  payload = "{"options":{"client_id":"","profile":true,"scope":["profile"],"upstream_params":{"blog":{"value":"myblog.wordpress.com"}}}}"

  headers = {
      'authorization': "Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      'content-type': "application/json"
      }

  conn.request("PATCH", "/{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D", payload, headers)

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

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

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

  url = URI("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/%7ByourWordpressConnectionId%7D")

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

  request = Net::HTTP::Patch.new(url)
  request["authorization"] = 'Bearer {YOUR_MANAGEMENT_API_TOKEN}'
  request["content-type"] = 'application/json'
  request.body = "{"options":{"client_id":"","profile":true,"scope":["profile"],"upstream_params":{"blog":{"value":"myblog.wordpress.com"}}}}"

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

これで、この接続でユーザーが認証されるたびに、WordPress 認可エンドポイントへのリクエストにクエリパラメーター `blog=myblog.wordpress.com` が含まれるようになります。

<div id="dynamic-parameters">
  ## 動的パラメーター
</div>

動的パラメーターを使用すると、ユーザーのログイン時に、そのユーザー固有の値を持つ一連のパラメーターを IdP に送信するよう接続を設定できます。

動的パラメーターを設定するには、Auth0 Management API の [Create a connection](https://auth0.com/docs/api/management/v2/#!/Connections/post_connections) または [Update a connection](https://auth0.com/docs/api/management/v2/#!/Connections/patch_connections_by_id) エンドポイントを呼び出し、IdP に送信するパラメーターを `options` オブジェクト内の `upstream_params` オブジェクトとして渡します。また、`alias` 属性を使用して、そのパラメーターのマッピング先となるフィールドを指定します。

以下は `options` オブジェクトのサンプルです。これについては後ほど X の例で再度取り上げます。

```json lines theme={null}
{
  "options": {
    "upstream_params": {
      "screen_name": {
        "alias": "login_hint"
      }
    }
  }
}
```

<div id="available-fields">
  ### 使用可能なフィールド
</div>

`alias` 属性で使用できるフィールドは次のとおりです。

* `acr_values`
* `audience`
* `client_id`
* `display`
* `id_token_hint`
* `login_hint`
* `max_age`
* `prompt`
* `resource`
* `response_mode`
* `response_type`
* `ui_locales`

<div id="example-x">
  ### 例: X
</div>

X では、OAuth 認可エンドポイントにオプションの `screen_name` パラメーターを渡せます。`screen_name` パラメーターを指定すると、ログイン画面の username 入力欄にその値が事前入力されます。詳しくは、[X の API リファレンス](https://docs.x.com/fundamentals/authentication/api-reference#get-oauth%2Fauthorize)を参照してください。

この例に従うには、動作する [X ソーシャル接続](https://marketplace.auth0.com/integrations/twitter-social-connection) が必要です。

<div id="get-the-connection">
  #### 接続を取得する
</div>

Management API の [Get a connection](https://auth0.com/docs/api/management/v2#!/Connections/get_connections_by_id) エンドポイントを呼び出し、`options` オブジェクトの現在の値を取得します。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}' \
    --header 'authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}' \
    --header 'content-type: application/json'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}");
  var request = new RestRequest(Method.GET);
  request.AddHeader("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}");
  request.AddHeader("content-type", "application/json");
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}"

  	req, _ := http.NewRequest("GET", url, nil)

  	req.Header.Add("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
  	req.Header.Add("content-type", "application/json")

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

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

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

  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.get("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}")
    .header("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
    .header("content-type", "application/json")
    .asString();
  ```

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

  var options = {
    method: 'GET',
    url: 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}',
    headers: {
      authorization: 'Bearer {YOUR_MANAGEMENT_API_TOKEN}',
      'content-type': 'application/json'
    }
  };

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

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

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      "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 theme={null}
  import http.client

  conn = http.client.HTTPSConnection("")

  headers = {
      'authorization': "Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      'content-type': "application/json"
      }

  conn.request("GET", "/{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}", headers=headers)

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

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

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

  url = URI("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}")

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

  request = Net::HTTP::Get.new(url)
  request["authorization"] = 'Bearer {YOUR_MANAGEMENT_API_TOKEN}'
  request["content-type"] = 'application/json'

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

`options` オブジェクトは、次のようになります。

```text lines theme={null}
"options": {
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET",
  "profile": true
}
```

<div id="update-the-connection-dynamic">
  #### 接続を更新する (動的)
</div>

既存の`options`オブジェクトをコピーし、属性として`screen_name`フィールドを含む`upstream_params`オブジェクトを追加したうえで、`alias`属性を`login_hint`に設定します:

```json lines theme={null}
{
  "options": {
    "client_id": "", 
    "profile": true, 
    "scope": ["profile"],
    "upstream_params": {
      "screen_name": {
        "alias": "login_hint"
      }
    }
  }
}
```

リクエスト本文に `options` オブジェクトを指定して、Management API の [Update a connection](https://auth0.com/docs/api/management/v2/#!/Connections/patch_connections_by_id) エンドポイントを呼び出します。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request PATCH \
    --url 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}' \
    --header 'authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}' \
    --header 'content-type: application/json' \
    --data '{"options": {"client_id": "{YOUR_CLIENT_ID}", "client_secret": "{YOUR_CLIENT_SECRET}", "profile": true, "upstream_params": {"screen_name": {"alias": "login_hint"}}}}'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}");
  var request = new RestRequest(Method.PATCH);
  request.AddHeader("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}");
  request.AddHeader("content-type", "application/json");
  request.AddParameter("application/json", "{"options": {"client_id": "{YOUR_CLIENT_ID}", "client_secret": "{YOUR_CLIENT_SECRET}", "profile": true, "upstream_params": {"screen_name": {"alias": "login_hint"}}}}", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}"

  	payload := strings.NewReader("{"options": {"client_id": "{YOUR_CLIENT_ID}", "client_secret": "{YOUR_CLIENT_SECRET}", "profile": true, "upstream_params": {"screen_name": {"alias": "login_hint"}}}}")

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

  	req.Header.Add("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
  	req.Header.Add("content-type", "application/json")

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

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

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

  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.patch("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}")
    .header("authorization", "Bearer {YOUR_MANAGEMENT_API_TOKEN}")
    .header("content-type", "application/json")
    .body("{"options": {"client_id": "{YOUR_CLIENT_ID}", "client_secret": "{YOUR_CLIENT_SECRET}", "profile": true, "upstream_params": {"screen_name": {"alias": "login_hint"}}}}")
    .asString();
  ```

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

  var options = {
    method: 'PATCH',
    url: 'https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}',
    headers: {
      authorization: 'Bearer {YOUR_MANAGEMENT_API_TOKEN}',
      'content-type': 'application/json'
    },
    data: {
      options: {
        client_id: '{YOUR_CLIENT_ID}',
        client_secret: '{YOUR_CLIENT_SECRET}',
        profile: true,
        upstream_params: {screen_name: {alias: 'login_hint'}}
      }
    }
  };

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

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

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PATCH",
    CURLOPT_POSTFIELDS => "{"options": {"client_id": "{YOUR_CLIENT_ID}", "client_secret": "{YOUR_CLIENT_SECRET}", "profile": true, "upstream_params": {"screen_name": {"alias": "login_hint"}}}}",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      "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 theme={null}
  import http.client

  conn = http.client.HTTPSConnection("")

  payload = "{"options": {"client_id": "{YOUR_CLIENT_ID}", "client_secret": "{YOUR_CLIENT_SECRET}", "profile": true, "upstream_params": {"screen_name": {"alias": "login_hint"}}}}"

  headers = {
      'authorization': "Bearer {YOUR_MANAGEMENT_API_TOKEN}",
      'content-type': "application/json"
      }

  conn.request("PATCH", "/{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}", payload, headers)

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

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

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

  url = URI("https://{YOUR_AUTH0_DOMAIN}/api/v2/connections/{YOUR_X_CONNECTION_ID}")

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

  request = Net::HTTP::Patch.new(url)
  request["authorization"] = 'Bearer {YOUR_MANAGEMENT_API_TOKEN}'
  request["content-type"] = 'application/json'
  request.body = "{"options": {"client_id": "{YOUR_CLIENT_ID}", "client_secret": "{YOUR_CLIENT_SECRET}", "profile": true, "upstream_params": {"screen_name": {"alias": "login_hint"}}}}"

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

<div id="call-the-login-endpoint">
  #### ログインエンドポイントを呼び出す
</div>

ユーザーに対して Authentication API の [Login endpoint](https://auth0.com/docs/api/authentication#login) を呼び出す際は、そのメールアドレスを `login_hint` パラメーターに渡すことができます。

export const codeExample41 = `https://{YOUR_AUTH0_DOMAIN}/authorize
  ?client_id={YOUR_CLIENT_ID}
  &response_type=token
  &redirect_uri={https://yourApp/callback}
  &scope=openid%20name%20email
  &login_hint=user@domain.com`;

<AuthCodeBlock children={codeExample41} language="bash" />

この値は、`screen_name` パラメーターとして X の認可エンドポイントに渡されます。

```text lines theme={null}
https://api.x.com/oauth/authorize
  ?oauth_token={yourXAuthToken}
  &screen_name=user@domain.com
```
