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

> OIDC 準拠パイプラインがリソース所有者パスワード（ROP）フローに与える影響について学びます。

# OIDC におけるリソース所有者パスワードフロー

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) + "*****MASKED*****";
          }
          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>;
};

[リソース所有者パスワードフロー](/docs/ja-jp/get-started/authentication-and-authorization-flow/resource-owner-password-flow) (<Tooltip tip="リソース所有者: 保護されたリソースへのアクセスを許可できるエンティティ（ユーザーやアプリケーションなど）。" cta="用語集を表示" href="/docs/ja-jp/glossary?term=Resource+Owner">リソース所有者</Tooltip> Password Grant または ROPG と呼ばれることもあります) は、高信頼アプリケーションがアクティブ認証を提供するために使用されます。認可コードグラントや Implicit grant とは異なり、この認証の仕組みではユーザーは Auth0 にリダイレクトされません。単一のリクエストでユーザーを認証し、パスワード資格情報をトークンと交換します。

OIDC 準拠パイプラインは、次の領域でリソース所有者パスワードフローに影響を与えます。

* 認証リクエスト
* 認証レスポンス
* <Tooltip tip="ID トークン: リソースへのアクセスではなく、クライアント自身を対象とした資格情報です。" cta="用語集を表示" href="/docs/ja-jp/glossary?term=ID+token">ID トークン</Tooltip> の構造
* <Tooltip tip="アクセストークン: API へのアクセスに使用される認可資格情報で、opaque な文字列または JWT の形式を取ります。" cta="用語集を表示" href="/docs/ja-jp/glossary?term=Access+token">アクセストークン</Tooltip> の構造

<div id="authentication-request">
  ## 認証リクエスト
</div>

### 従来

```json lines theme={null}
POST /oauth/ro HTTP 1.1
Content-Type: application/json
{
  "grant_type": "password",
  "client_id": "123",
  "username": "alice",
  "password": "A3ddj3w",
  "connection": "my-database-connection",
  "scope": "openid email favorite_color offline_access",
  "device": "my-device-name"
}
```

`offline_access` スコープを指定して<Tooltip tip="リフレッシュトークン: ユーザーに再度ログインさせることなく、新しいアクセストークンを取得するために使用するトークン。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=refresh+token">リフレッシュトークン</Tooltip>をリクエストする場合にのみ、`device` パラメータが必要です。

<div id="oidc-conformant">
  ### OIDC 準拠
</div>

```json lines theme={null}
POST /oauth/token HTTP 1.1
Content-Type: application/x-www-form-urlencoded
grant_type=http%3A%2F%2Fauth0.com%2Foauth%2Fgrant-type%2Fpassword-realm&client_id=123&username=alice&password=A3ddj3w&realm=my-database-connection&scope=openid+email+offline_access&audience=https%3A%2F%2Fapi.example.com
```

* 認証情報交換に使用するエンドポイントは `/oauth/token` です。
* Auth0 独自のグラントタイプは、特定の接続 (`realm`) に属するユーザーを認証するために使用されます。標準の OIDC パスワードグラントもサポートされていますが、`realm` などの Auth0 固有のパラメーターは受け付けません。
* `favorite_color` は、現在は有効なスコープではありません。
* `device` パラメーターは削除されました。
* `audience` パラメーターは省略可能です。

<div id="authentication-response">
  ## 認証レスポンス
</div>

### 従来

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
{
    "access_token": "SlAV32hkKG",
    "token_type": "Bearer",
    "refresh_token": "8xLOxBtZp8",
    "expires_in": 3600,
    "id_token": "eyJ..."
}
```

* 返されたアクセストークンは、[`/userinfo`](https://auth0.com/docs/api/authentication#get-user-info)エンドポイントの呼び出しにのみ使用できます。
* リフレッシュトークンは、`device` パラメータが渡され、`offline_access` スコープが要求された場合にのみ返されます。

<div id="oidc-conformant">
  ### OIDC 準拠
</div>

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
{
    "access_token": "eyJ...",
    "token_type": "Bearer",
    "refresh_token": "8xLOxBtZp8",
    "expires_in": 3600,
    "id_token": "eyJ..."
}
```

* 返されるアクセストークンは、`/userinfo` エンドポイントの呼び出しに有効です (`audience` パラメーターで指定された API が [署名アルゴリズム](/docs/ja-jp/get-started/applications/signing-algorithms) として `RS256` を使用している場合) 。また、必要に応じて `audience` パラメーターで指定された <Tooltip tip="Resource Server: 保護されたリソースをホストするサーバー。リソースサーバーは保護されたリソースへのリクエストを受け取り、応答します。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=resource+server">リソースサーバー</Tooltip> に対しても有効です。
* パブリックアプリケーションによって要求された場合、ID トークンは強制的に `RS256` で署名されます。詳しくは、[Confidential and Public Applications](/docs/ja-jp/get-started/applications/confidential-and-public-applications) を参照してください。
* リフレッシュトークンが返されるのは、`offline_access` スコープが付与された場合のみです。

<div id="id-token-structure">
  ## ID トークンの構造
</div>

<div id="legacy">
  ### レガシー
</div>

export const codeExample1 = `{
    "sub": "auth0|alice",
    "iss": "https://{yourDomain}/",
    "aud": "123",
    "exp": 1482809609,
    "iat": 1482773609,
    "email": "alice@example.com",
    "email_verified": true,
    "favorite_color": "blue"
}`;

<AuthCodeBlock children={codeExample1} language="json" filename="JSON" />

<div id="oidc-conformant">
  ### OIDC 準拠
</div>

export const codeExample2 = `{
    "sub": "auth0|alice",
    "iss": "https://{yourDomain}/",
    "aud": "123",
    "exp": 1482809609,
    "iat": 1482773609,
    "email": "alice@example.com",
    "email_verified": true,
    "https://app.example.com/favorite_color": "blue"
}`;

<AuthCodeBlock children={codeExample2} language="json" filename="JSON" />

* ID トークンは、パブリックアプリケーションから要求された場合、強制的に `RS256` で署名されます。
* `favorite_color` クレームは名前空間付きにし、ルールを使って追加する必要があります。詳しくは、[名前空間付きカスタムクレームを作成する](/docs/ja-jp/secure/tokens/json-web-tokens/create-custom-claims) をご覧ください。

<div id="access-token-structure-optional">
  ## アクセストークンの構造 (オプション)
</div>

### 従来方式

```json JSON lines theme={null}
SlAV32hkKG
```

返されたアクセストークンはopaqueで、`/userinfo`エンドポイントの呼び出しにのみ有効です。

<div id="oidc-conformant">
  ### OIDC 準拠
</div>

export const codeExample3 = `{
    "sub": "auth0|alice",
    "iss": "https://{yourDomain}/",
    "aud": [
        "https://api.example.com",
        "https://{yourDomain}/userinfo"
    ],
    "azp": "123",
    "exp": 1482816809,
    "iat": 1482809609,
    "scope": "openid email"
}`;

<AuthCodeBlock children={codeExample3} language="json" filename="JSON" />

* 返されるアクセストークンは、<Tooltip tip="JSON Web Token (JWT): 2者間でクレームを安全に表現するために使用される標準的な ID トークン形式（多くの場合アクセストークン形式でもあります）。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=JWT">JWT</Tooltip> であり、`/userinfo` エンドポイントの呼び出しに有効です (`audience` パラメータで指定された API が <Tooltip tip="Signing Algorithm: トークンが改ざんされていないことを保証するために、トークンに電子署名する際に使用されるアルゴリズムです。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=signing+algorithm">署名アルゴリズム</Tooltip> として `RS256` を使用している場合) 。また、`audience` パラメータで指定されたリソースサーバーに対しても有効です。
* 指定された <Tooltip tip="Audience: 発行されたトークンの audience を表す一意の識別子です。トークン内では aud という名前で表され、その値には ID トークンの場合はアプリケーション（Client ID）の ID、アクセストークンの場合は API（API Identifier）の ID が含まれます。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=audience">オーディエンス</Tooltip> が `/userinfo` のみである場合でも、opaque なアクセストークンが返される可能性があることに注意してください。

<div id="standard-password-grant-requests">
  ## 標準のパスワードグラントリクエスト
</div>

Auth0 の password realm grant は標準の OIDC では定義されていませんが、Auth0 固有の `realm` パラメータをサポートしているため、従来のリソース所有者エンドポイントに代わるものとして推奨されています。OIDC 認証を使用する場合は、[標準の OIDC フローもサポートされています](/docs/ja-jp/get-started/authentication-and-authorization-flow/resource-owner-password-flow)。

<div id="learn-more">
  ## さらに詳しく
</div>

* [OIDCでのアクセストークン](/docs/ja-jp/authenticate/login/oidc-conformant-authentication/oidc-adoption-access-tokens)
* [OIDCでの外部API](/docs/ja-jp/authenticate/login/oidc-conformant-authentication/oidc-adoption-apis)
* [OIDCでの認可コードフロー](/docs/ja-jp/authenticate/login/oidc-conformant-authentication/oidc-adoption-auth-code-flow)
* [OIDCでのクライアント認証情報フロー](/docs/ja-jp/authenticate/login/oidc-conformant-authentication/oidc-adoption-client-credentials-flow)
* [OIDCでのImplicit Flow](/docs/ja-jp/authenticate/login/oidc-conformant-authentication/oidc-adoption-implicit-flow)
* [OIDCでのリフレッシュトークン](/docs/ja-jp/authenticate/login/oidc-conformant-authentication/oidc-adoption-refresh-tokens)
