

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# API 和 SDK 身分驗證的授權模型
<a name="authentication-flows-public-server-side"></a>

當您使用使用者集區身分驗證開始開發應用程式時，您必須決定適合您應用程式類型的 API 授權模型。授權模型是一種系統，用於提供授權，以使用 Amazon Cognito 使用者集區 API 和 SDK 整合中的身分驗證元件提出請求。Amazon Cognito 有三種授權模式：IAM 授權、公有和字符授權。

使用 IAM 授權請求時，授權來自請求`Authorization`標頭中一組 AWS IAM 登入資料的簽章。對於伺服器端應用程式，此實務會使用 IAM 授權保護身分驗證操作。對於公有 （未驗證） 身分驗證請求，不需要授權。這適用於分發給使用者的用戶端應用程式。使用字符授權的操作，通常與公有操作結合實作，授權來自工作階段字符或包含在請求`Authorization`標頭中的存取字符。Amazon Cognito 身分驗證通常會要求您依序實作兩個或多個 API 操作，而您使用的 API 操作取決於應用程式的特性。應用程式分發給使用者的公有用戶端會使用公有操作，其中登入請求不需要授權。字符授權的操作會在公有應用程式中繼續使用者工作階段。伺服器端用戶端，其中應用程式邏輯託管在遠端系統上，透過登入請求的 IAM 授權來保護身分驗證操作。後面的 API 操作對及其對應的 SDK 方法會映射到可用的授權模型。

每個公有身分驗證操作都有某種形式的伺服器端對等項目，例如 [UpdateUserAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserAttributes.html) 和 [AdminUpdateUserAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUpdateUserAttributes.html)。雖然用戶端操作是由使用者啟動且需要確認，但伺服器端操作假設變更是由使用者集區管理員所遞交，且變更會立即生效。在此範例中，Amazon Cognito 會傳送包含確認碼的訊息給使用者，而使用者的存取權杖會授權提交程式碼的 [VerifyUserAttribute](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifyUserAttribute.html) 請求。伺服器端應用程式可以立即設定任何屬性的值，但是在用於登入時，變更電子郵件地址和電話號碼的值[會受到特殊考量](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUpdateUserAttributes.html#CognitoUserPools-AdminUpdateUserAttributes-request-UserAttributes)。

若要比較 API 身分驗證並查看 API 操作及其授權模型的完整清單，請參閱 [了解 API、OIDC 和受管登入頁面身分驗證](#user-pools-API-operations)。

------
#### [ Client-side (public) authentication ]

以下是用戶端應用程式中典型的一系列請求

1. 公有 [InitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html) 操作會提交主要登入資料，例如使用者名稱和密碼。

1. 權杖授權的 [RespondToAuthChallenge](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_RespondToAuthChallenge.html) 操作會從`InitiateAuth`回應和挑戰的答案提交*工作階段*權杖，例如 MFA。工作階段字符授權表示請求屬於not-yet-complete身分驗證週期的一部分。

1. 權杖授權的 [ConfirmDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmDevice.html) 操作會提交*存取權*杖，並執行將記住的裝置新增至使用者設定檔的寫入操作。存取字符授權表示在使用者完成身分驗證後，適用於使用者自助式操作的請求。

如需詳細資訊，請參閱[用戶端身分驗證選項](#amazon-cognito-user-pools-client-side-authentication-flow)及[了解 API、OIDC 和受管登入頁面身分驗證](#user-pools-API-operations)。

------
#### [ Server-side authentication ]

以下是伺服器端操作的典型請求序列。每個請求都有[AWS 簽章第 4 版](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html)授權標頭，該標頭使用發行給應用程式伺服器的 IAM 機器登入資料簽署。

1. [AdminInitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html) 操作會提交主要登入資料，例如使用者名稱和密碼。

1. [AdminRespondToAuthChallenge](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminRespondToAuthChallenge.html) 操作會將答案提交至挑戰，例如 MFA。

1. [AdminUpdateDeviceStatus](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUpdateDeviceStatus.html) 操作會將來自`AdminInitiateAuth`[回應](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html#API_AdminInitiateAuth_ResponseSyntax)的裝置金鑰設定為記住。

如需詳細資訊，請參閱[伺服器端身分驗證選項](#amazon-cognito-user-pools-server-side-authentication-flow)及[了解 API、OIDC 和受管登入頁面身分驗證](#user-pools-API-operations)。

------

使用者身分驗證會透過回答連續挑戰，直到驗證失敗或者 Amazon Cognito 發出權杖給使用者。您可以使用 Amazon Cognito 在包含不同挑戰的程序中重複這些步驟，以支援任何自訂的身分驗證流程。

**Topics**
+ [伺服器端身分驗證選項](#amazon-cognito-user-pools-server-side-authentication-flow)
+ [用戶端身分驗證選項](#amazon-cognito-user-pools-client-side-authentication-flow)
+ [了解 API、OIDC 和受管登入頁面身分驗證](#user-pools-API-operations)
+ [依授權模型分組的 API 操作清單](#user-pool-apis-auth-unauth)

## 伺服器端身分驗證選項
<a name="amazon-cognito-user-pools-server-side-authentication-flow"></a>

Web 應用程式和其他*伺服器端*應用程式會在用戶端載入遠端顯示應用程式的遠端伺服器上實作身分驗證，例如瀏覽器或 SSH 工作階段。伺服器端應用程式通常具有下列特性。
+ 它們內建於安裝在伺服器上的應用程式，使用 Java、Ruby 或 Node.js 等語言。
+ 它們連接到可能有用戶端秘密的使用者集區[應用程式用戶端](user-pool-settings-client-apps.md)，稱為*機密用戶端*。
+ 他們可以存取 AWS 登入資料。
+ 他們叫用[受管登入](cognito-user-pools-managed-login.md)以進行身分驗證，或在使用者集區 API 中使用 IAM 授權的操作搭配 AWS SDK。
+ 它們為內部客戶提供服務，並可能為公眾客戶提供服務。

使用使用者集區 API 的伺服器端操作可以使用密碼、一次性密碼或通行密鑰作為主要登入因素。如果是伺服器端應用程式，使用者集區身分驗證類似於用戶端應用程式的身分驗證，但以下除外：
+ 伺服器端應用程式會發出 [AdminInitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html) API 請求。此操作需要具有包含 `cognito-idp:AdminInitiateAuth`和 許可的 AWS 登入資料`cognito-idp:AdminRespondToAuthChallenge`。操作會傳回所需的挑戰或身分驗證結果。
+ 當應用程式收到挑戰時，它會發出 [AdminRespondToAuthChallenge](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminRespondToAuthChallenge.html) API 請求。`AdminRespondToAuthChallenge` API 操作也需要 AWS 登入資料。

如需使用 AWS 登入資料簽署 Amazon Cognito API 請求的詳細資訊，請參閱《 *AWS 一般參考*》中的 [Signature 第 4 版簽署程序](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html)。

在 `AdminInitiateAuth` 回應 `ChallengeParameters` 中，`USER_ID_FOR_SRP` 屬性 (如果存在) 將會包含使用者的實際使用者名稱，而不是別名 (例如電子郵件地址或電話號碼)。在呼叫 `AdminRespondToAuthChallenge` 期間，在 `ChallengeResponses` 中，您必須在 `USERNAME` 參數中傳遞此使用者名稱。

**注意**  
由於後端管理員實作使用管理員身分驗證流程，因此流程不支援記住的裝置。當您開啟裝置追蹤功能時，管理員身分驗證會成功，但是用來重新整理存取權杖的任何呼叫都會失敗。

## 用戶端身分驗證選項
<a name="amazon-cognito-user-pools-client-side-authentication-flow"></a>

行動應用程式和其他*用戶端*應用程式類型安裝在使用者的裝置上，並在本機執行身分驗證和使用者介面的邏輯。它們通常具有下列特性。
+ 它們內建於 React 原生、Flutter 和 Swift 等語言，並部署到使用者裝置。
+ 它們連接到沒有用戶端秘密的使用者集區[應用程式用戶端](user-pool-settings-client-apps.md)，稱為*公有用戶端*。
+ 他們無法存取會授權 IAM 授權 API 請求的 AWS 登入資料。
+ 他們叫用[受管登入](cognito-user-pools-managed-login.md)進行身分驗證，或在使用者集區 API 中使用公有和字符授權的操作搭配 AWS SDK。
+ 它們為公眾客戶提供服務，並允許任何人註冊和登入。

使用使用者集區 API 的用戶端操作可以使用密碼、一次性密碼或通行金鑰作為主要登入因素。以下程序適用於您使用 [AWS Amplify](https://docs.amplify.aws/javascript/start/getting-started/) 或 [AWS SDK](https://aws.amazon.com/developer/tools/) 所建立的使用者用戶端應用程式。

1. 使用者在應用程式中輸入使用者名稱和密碼。

1. 應用程式會以使用者的使用者名稱和安全遠端密碼 (SRP) 詳細資訊呼叫 `InitiateAuth` 操作。

   此 API 操作會傳回驗證參數。
**注意**  
此應用程式使用 AWS SDK 內建的 Amazon Cognito SRP 功能產生 SRP 詳細資訊。

1. 應用程式會呼叫 `RespondToAuthChallenge` 操作。如果呼叫成功，Amazon Cognito 會傳回使用者的權杖，身分驗證流程便已完成。

   如果 Amazon Cognito 需要另一個挑戰，對 `RespondToAuthChallenge` 的呼叫就不會傳回任何權杖。相反地，呼叫會傳回工作階段。

1. 如果 `RespondToAuthChallenge` 傳回工作階段，應用程式會再次呼叫 `RespondToAuthChallenge`，這次會使用工作階段和挑戰回應 (例如，MFA 程式碼)。

## 了解 API、OIDC 和受管登入頁面身分驗證
<a name="user-pools-API-operations"></a>

Amazon Cognito 使用者集區是多種身分驗證技術的組合。他們倚賴外部身分提供者 IdPs)。它們是使用 OpenID Connect (OIDC) SDKs 實作身分驗證之應用程式的 IdPs。它們以類似 OIDC 身分驗證的 JSON Web 權杖 (JWTs) 發行者身分驗證，但在屬於 AWS SDKs 的 API 方法中提供身分驗證。它們也可以是應用程式的安全進入點。

當您想要註冊、登入和管理使用者集區中的使用者，您有兩種選擇。

1. 您的*受管登入頁面*和傳統*託管 UI* 包括[受管登入使用者互動端點](managed-login-endpoints.md)，以及處理 IdP 和依賴方角色的[聯合端點](federation-endpoints.md)。在您為使用者集區[選擇網域](cognito-user-pools-assign-domain.md)時，會共同組成 Amazon Cognito 啟用的公開網頁套件。若要快速開始使用 Amazon Cognito 使用者集區的身分驗證和授權功能，包括註冊、登入、密碼管理和多重要素驗證 (MFA) 的頁面，請使用 受管登入的內建使用者介面。

   其他使用者集區端點有助於通過第三方身分提供者 (IdP) 的身分驗證。執行的服務包括下列項目。

   1. 服務提供者回呼來自 IdP 的已驗證宣告的端點，例如 `saml2/idpresponse` 和 `oauth2/idpresponse`。當 Amazon Cognito 是應用程式和 IdP 之間的中繼服務提供者 (SP) 時，回呼端點代表該服務。

   1. 提供環境相關資訊的端點，例如 `oauth2/userInfo` 和 `/.well-known/jwks.json`。您的應用程式會在驗證字符或使用 OIDC 或 OAuth 2.0 開發人員程式庫擷取使用者設定檔資料時，使用這些端點。

1. [Amazon Cognito 使用者集區 API](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html) 是一組工具，可供您的 Web 或行動應用程式在您自己的自訂前端收集登入資訊後驗證使用者。使用者集區 API 驗證會產生下列 JSON Web 權杖。

   1. 使用者具有驗證屬性宣告的身分權杖。

   1. 存取權杖授權使用者向 [AWS 服務端點](https://docs.aws.amazon.com/general/latest/gr/cognito_identity.html)建立權杖授權的 API 請求。
**注意**  
預設中，來自使用者集區 API 身分驗證的存取權杖僅包含 `aws.cognito.signin.user.admin` 範圍。如果您想要產生具有其他範圍的存取權杖，例如授權對第三方 API 的請求，請透過使用者集區端點在驗證時要求範圍，或在 [產生權杖前 Lambda 觸發程序](user-pool-lambda-pre-token-generation.md) 中新增自訂範圍。存取權杖自訂會為您的 AWS 帳單增加成本。

   1. 重新整理字符，可授權新 ID 和存取字符的請求，並重新整理使用者身分和存取控制屬性。

您可以將通常透過使用者集區端點登入的聯合身分使用者連結至您使用者集區的本機身分使用者。本機使用者僅存在於您的使用者集區目錄中，不會透過外部 IdP 進行聯合。如果您在 [AdminLinkProviderForUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminLinkProviderForUser.html) API 請求中將其聯合身分連結至本機使用者，則他們可以使用使用者集區 API 登入。如需詳細資訊，請參閱[將聯合身分使用者連結至現有的使用者描述檔](cognito-user-pools-identity-federation-consolidate-users.md)。

Amazon Cognito 使用者集區 API 有雙重用途。

1. 它會建立和設定您的 Amazon Cognito 使用者集區資源。例如，您可以建立使用者集區、新增 AWS Lambda 觸發，以及設定託管受管登入頁面的使用者集區網域。

1. 它會為本機和連結的使用者執行註冊、登入和其他使用者操作。

**Amazon Cognito 使用者集區 API 的範例案例**

1. 您的使用者選擇您在應用中建立的「建立帳戶」按鈕。他們輸入電子郵件地址和密碼。

1. 您的應用程式傳送 [SignUp](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SignUp.html) API 請求，並在使用者集區中建立新使用者。

1. 您的應用程式提示使用者輸入電子郵件確認碼。您的使用者輸入他們在電子郵件訊息中收到的代碼。

1. 您的應用程式傳送帶有使用者確認代碼的 [ConfirmSignUp](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmSignUp.html) API 請求。

1. 您的應用程式會提示您的使用者輸入其使用者名稱和密碼，然後輸入其資訊。

1. 您的應用程式傳送 [InitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html) API 請求並儲存 ID 權杖、存取權杖和重新整理權杖。您的應用程式會呼叫 OIDC 程式庫以管理使用者權杖並維持該使用者的持久性工作階段。

在 Amazon Cognito 使用者集區 API 中，您無法登入透過 IdP 聯合的使用者。您必須透過使用者集區端點驗證這些使用者。如需包含受管登入之使用者集區端點的詳細資訊，請參閱 [使用者集區端點和受管登入參考](cognito-userpools-server-contract-reference.md)。

您的聯合身分使用者可以從受管登入開始並選取其 IdP，或者您可以略過受管登入，並將使用者直接傳送到您的 IdP 來登入。當您對 [授權端點](authorization-endpoint.md) 的 API 請求包含 IdP 參數時，Amazon Cognito 會以無訊息方式將您的使用者重新導向至 IdP 登入頁面。

**具有受管登入頁面的範例案例**

1. 您的使用者選擇您在應用中建立的「建立帳戶」按鈕。

1. 受管登入會為您的使用者提供您已註冊開發人員登入資料的社交身分提供者清單。您的使用者選擇 Apple。

1. 您的應用程式會以提供者名稱 `SignInWithApple` 向 [授權端點](authorization-endpoint.md) 展開請求。

1. 您使用者的瀏覽器會開啟 Apple 身分驗證頁面。您的使用者登入並選擇授權 Amazon Cognito 讀取其設定檔資訊。

1. Amazon Cognito 確認 Apple 存取權杖並查詢使用者的 Apple 設定檔。

1. 您的使用者會向您的應用程式提供 Amazon Cognito 授權碼。

1. 應用程式中的 OIDC 程式庫會與 交換授權碼，[權杖端點](token-endpoint.md)並存放使用者集區發出的 ID 字符、存取字符和重新整理字符。您的應用程式使用 OIDC 程式庫來管理使用者的字符，並維護該使用者的持久性工作階段。

使用者集區 API 和受管登入頁面支援各種案例，如本指南所述。以下各節將探討使用者集區 API 如何進一步劃分為支援您註冊、登入和資源管理需求的類別。

## 依授權模型分組的 API 操作清單
<a name="user-pool-apis-auth-unauth"></a>

Amazon Cognito 使用者集區 API (同時是資源管理介面和面向使用者的身分驗證和授權介面) 根據其操作結合授權模型。根據 API 操作，您可能必須提供 IAM 憑證、存取權杖、工作階段權杖、用戶端秘密，或是以上的組合來提供授權。對於許多使用者身分驗證和授權操作，您可以選擇經身分驗證和未進行身分驗證的請求版本。對於分發給使用者的應用程式 (例如行動應用程式) 而言，未進行身分驗證的操作是最佳安全實務；您不需要在程式碼中加入任何秘密。

您只能在 [IAM 授權的管理操作](#user-pool-apis-auth-unauth-sigv4-management) 和 [IAM 授權的使用者操作](#user-pool-apis-auth-unauth-sigv4-user) 的 IAM 政策中指派許可。

### IAM 授權的管理操作
<a name="user-pool-apis-auth-unauth-sigv4-management"></a>

IAM 授權的管理操作會修改和檢視您的使用者集區和應用程式用戶端組態，就像您在 中所做的一樣 AWS 管理主控台。

例如，若要修改 [UpdateUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPool.html) API 請求中的使用者集區，您必須提供 AWS 登入資料和 IAM 許可以更新資源。

若要在 AWS Command Line Interface (AWS CLI) 或 AWS SDK 中授權這些請求，請使用將 IAM 登入資料新增至請求的環境變數或用戶端組態來設定您的環境。如需詳細資訊，請參閱《》中的[AWS 使用您的 AWS 登入資料存取](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) *AWS 一般參考*。您也可以將請求直接傳送到 Amazon Cognito 使用者集區 API 的[服務端點](https://docs.aws.amazon.com/general/latest/gr/cognito_identity.html)。您必須使用內嵌在請求標頭中的 AWS 登入資料來授權或*簽署*這些請求。如需詳細資訊，請參閱[簽署 AWS API 請求](https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html)。


| IAM 授權的管理操作 | 
| --- |
| [AddCustomAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AddCustomAttributes.html) | 
| [CreateGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateGroup.html) | 
| [CreateIdentityProvider](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateIdentityProvider.html) | 
| [CreateResourceServer](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateResourceServer.html) | 
| [CreateUserImportJob](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserImportJob.html) | 
| [CreateUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPool.html) | 
| [CreateUserPoolClient](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolClient.html) | 
| [CreateUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolDomain.html) | 
| [DeleteGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteGroup.html) | 
| [DeleteIdentityProvider](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteIdentityProvider.html) | 
| [DeleteResourceServer](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteResourceServer.html) | 
| [DeleteUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteUserPool.html) | 
| [DeleteUserPoolClient](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteUserPoolClient.html) | 
| [DeleteUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteUserPoolDomain.html) | 
| [DescribeIdentityProvider](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeIdentityProvider.html) | 
| [DescribeResourceServer](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeResourceServer.html) | 
| [DescribeRiskConfiguration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeRiskConfiguration.html) | 
| [DescribeUserImportJob](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserImportJob.html) | 
| [DescribeUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPool.html) | 
| [DescribeUserPoolClient](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPoolClient.html) | 
| [DescribeUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPoolDomain.html) | 
| [GetCSVHeader](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetCSVHeader.html) | 
| [GetGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetGroup.html) | 
| [GetIdentityProviderByIdentifier](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetIdentityProviderByIdentifier.html) | 
| [GetSigningCertificate](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetSigningCertificate.html) | 
| [GetUICustomization](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUICustomization.html) | 
| [GetUserPoolMfaConfig](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUserPoolMfaConfig.html) | 
| [ListGroups](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListGroups.html) | 
| [ListIdentityProviders](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListIdentityProviders.html) | 
| [ListResourceServers](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListResourceServers.html) | 
| [ListTagsForResource](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListTagsForResource.html) | 
| [ListUserImportJobs](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUserImportJobs.html) | 
| [ListUserPoolClients](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUserPoolClients.html) | 
| [ListUserPools](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUserPools.html) | 
| [ListUsers](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html) | 
| [ListUsersInGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsersInGroup.html) | 
| [SetRiskConfiguration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetRiskConfiguration.html) | 
| [SetUICustomization](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetUICustomization.html) | 
| [SetUserPoolMfaConfig](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetUserPoolMfaConfig.html) | 
| [StartUserImportJob](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_StartUserImportJob.html) | 
| [StopUserImportJob](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_StopUserImportJob.html) | 
| [TagResource](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_TagResource.html) | 
| [UntagResource](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UntagResource.html) | 
| [UpdateGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateGroup.html) | 
| [UpdateIdentityProvider](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateIdentityProvider.html) | 
| [UpdateResourceServer](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateResourceServer.html) | 
| [UpdateUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPool.html) | 
| [UpdateUserPoolClient](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPoolClient.html) | 
| [UpdateUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPoolDomain.html) | 

### IAM 授權的使用者操作
<a name="user-pool-apis-auth-unauth-sigv4-user"></a>

IAM 授權的使用者操作註冊、登入、管理登入資料、修改和檢視您的使用者。

例如，您可以擁有一個支援 Web 前端的伺服器端應用程式層。您的伺服器端應用程式是您信任的 OAuth 機密用戶端，可獲得 Amazon Cognito 資源的特殊權限存取權。若要在應用程式中註冊使用者，您的伺服器可以在 [AdminCreateUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html) API 請求中包含 AWS 憑證。有關 OAuth 用戶端類型的詳細資訊，請參閱 *OAuth 2.0 授權架構*中的[用戶端類型](https://www.rfc-editor.org/rfc/rfc6749#section-2.1)。

若要在 AWS CLI 或 AWS SDK 中授權這些請求，請使用將 IAM 登入資料新增至請求的環境變數或用戶端組態來設定伺服器端應用程式環境。如需詳細資訊，請參閱《》中的[AWS 使用您的 AWS 登入資料存取](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) *AWS 一般參考*。您也可以將請求直接傳送到 Amazon Cognito 使用者集區 API 的[服務端點](https://docs.aws.amazon.com/general/latest/gr/cognito_identity.html)。您必須使用內嵌在請求標頭中的 AWS 登入資料來授權或*簽署*這些請求。如需詳細資訊，請參閱[簽署 AWS API 請求](https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html)。

如果您的應用程式用戶端具有用戶端秘密，您必須同時提供 IAM 憑證，並根據操作提供 `SecretHash` 參數或 `AuthParameters` 中的 `SECRET_HASH` 值。如需詳細資訊，請參閱[運算私密雜湊值](signing-up-users-in-your-app.md#cognito-user-pools-computing-secret-hash)。


| IAM 授權的使用者操作 | 
| --- |
| [AdminAddUserToGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminAddUserToGroup.html) | 
| [AdminConfirmSignUp](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminConfirmSignUp.html) | 
| [AdminCreateUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html) | 
| [AdminDeleteUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminDeleteUser.html) | 
| [AdminDeleteUserAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminDeleteUserAttributes.html) | 
| [AdminDisableProviderForUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminDisableProviderForUser.html) | 
| [AdminDisableUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminDisableUser.html) | 
| [AdminEnableUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminEnableUser.html) | 
| [AdminForgetDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminForgetDevice.html) | 
| [AdminGetDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminGetDevice.html) | 
| [AdminGetUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminGetUser.html) | 
| [AdminInitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html) | 
| [AdminLinkProviderForUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminLinkProviderForUser.html) | 
| [AdminListDevices](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminListDevices.html) | 
| [AdminListGroupsForUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminListGroupsForUser.html) | 
| [AdminListUserAuthEvents](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminListUserAuthEvents.html) | 
| [AdminRemoveUserFromGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminRemoveUserFromGroup.html) | 
| [AdminResetUserPassword](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminResetUserPassword.html) | 
| [AdminRespondToAuthChallenge](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminRespondToAuthChallenge.html) | 
| [AdminSetUserMFAPreference](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminSetUserMFAPreference.html) | 
| [AdminSetUserPassword](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminSetUserPassword.html) | 
| [AdminSetUserSettings](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminSetUserSettings.html) | 
| [AdminUpdateAuthEventFeedback](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUpdateAuthEventFeedback.html) | 
| [AdminUpdateDeviceStatus](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUpdateDeviceStatus.html) | 
| [AdminUpdateUserAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUpdateUserAttributes.html) | 
| [AdminUserGlobalSignOut](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUserGlobalSignOut.html) | 

### 未經身分驗證的使用者操作
<a name="user-pool-apis-auth-unauth-unauth"></a>

未經身分驗證的使用者操作為您的使用者註冊、登入及啟動密碼重設。當您希望網際網路上的任何人註冊並登入您的應用程式，請使用未經身分驗證或*公有* API 操作。

例如，要在您的應用程式中註冊使用者，您可以分發 OAuth 公有用戶端，該用戶端不提供對秘密的特殊存取權限。您可以未經身分驗證的 API 操作 [SignUp](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SignUp.html) 註冊此使用者。

若要在您使用 AWS SDK 開發的公有用戶端中傳送這些請求，您不需要設定任何登入資料。您也可以將請求直接傳送到 Amazon Cognito 使用者集區 API 的[服務端點](https://docs.aws.amazon.com/general/latest/gr/cognito_identity.html)，不需要額外授權。

如果您的應用程式用戶端具有用戶端秘密，則必須根據操作提供 `SecretHash` 參數或 `AuthParameters` 中的 `SECRET_HASH` 值。如需詳細資訊，請參閱[運算私密雜湊值](signing-up-users-in-your-app.md#cognito-user-pools-computing-secret-hash)。


| 未經身分驗證的使用者操作 | 
| --- |
| [SignUp](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SignUp.html) | 
| [ConfirmSignUp](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmSignUp.html) | 
| [ResendConfirmationCode](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ResendConfirmationCode.html) | 
| [ForgotPassword](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ForgotPassword.html) | 
| [ConfirmForgotPassword](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmForgotPassword.html) | 
| [InitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html) | 

### 權杖授權的使用者操作
<a name="user-pool-apis-auth-unauth-token-auth"></a>

權杖授權的使用者操作會在使用者登入或開始登入程序後，登出、管理憑證、修改和檢視您的使用者。如果您不想在應用程式中分發秘密，並且想要以使用者自己的憑證授權請求時，請使用權杖授權 API 操作。如果您的使用者已完成登入，則必須使用存取權杖授權其權杖授權的 API 請求。如果您的使用者正在進行登入程序，您必須使用 Amazon Cognito 在回應先前請求時傳回的工作階段權杖來授權其權杖授權的 API 請求。

例如，在公有用戶端中，您可能會想要將更新使用者設定檔的寫入存取權限，限制為僅針對使用者自己的設定檔。若要進行此更新，您的用戶端可以在 [UpdateUserAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserAttributes.html) API 請求中包含使用者的存取權杖。

若要在您使用 AWS SDK 開發的公有用戶端中傳送這些請求，您不需要設定任何登入資料。在請求中包含 `AccessToken` 或 `Session` 參數。您也可以將請求直接傳送到 Amazon Cognito 使用者集區 API 的[服務端點](https://docs.aws.amazon.com/general/latest/gr/cognito_identity.html)。要授權對服務端點的請求，請在請求的 POST 內文中包含存取或工作階段權杖。

若要簽署權杖授權操作的 API 請求，請在請求中以 `Bearer <Base64-encoded access token>` 格式包括存取權杖作為 `Authorization` 標頭。


| 權杖授權的使用者操作 | AccessToken | Session (工作階段) | 
| --- |--- |--- |
| [RespondToAuthChallenge](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_RespondToAuthChallenge.html) |  | ✓ | 
| [ChangePassword](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ChangePassword.html) | ✓ |  | 
| [GetUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUser.html) | ✓ |  | 
| [StartWebAuthnRegistration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_StartWebAuthnRegistration.html) | ✓ |  | 
| [CompleteWebAuthnRegistration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CompleteWebAuthnRegistration.html) | ✓ |  | 
| [DeleteWebAuthnCredential](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteWebAuthnCredential.html) | ✓ |  | 
| [ListWebAuthnCredentials](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListWebAuthnCredentials.html) | ✓ |  | 
| [UpdateUserAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserAttributes.html) | ✓ |  | 
| [DeleteUserAttributes](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteUserAttributes.html) | ✓ |  | 
| [DeleteUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteUser.html) | ✓ |  | 
| [ConfirmDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmDevice.html) | ✓ |  | 
| [ForgetDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ForgetDevice.html) | ✓ |  | 
| [GetDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetDevice.html) | ✓ |  | 
| [ListDevices](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html) | ✓ |  | 
| [UpdateDeviceStatus](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateDeviceStatus.html) | ✓ |  | 
| [GetUserAttributeVerificationCode](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUserAttributeVerificationCode.html) | ✓ |  | 
| [VerifyUserAttribute](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifyUserAttribute.html) | ✓ |  | 
| [SetUserSettings](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetUserSettings.html) | ✓ |  | 
| [SetUserMFAPreference](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetUserMFAPreference.html) | ✓ |  | 
| [GlobalSignOut](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GlobalSignOut.html) | ✓ |  | 
| [UpdateAuthEventFeedback](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateAuthEventFeedback.html) |  | ✓ | 
| [AssociateSoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AssociateSoftwareToken.html) | ✓ | ✓ | 
| [VerifySoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifySoftwareToken.html) | ✓ | ✓ | 
| [RevokeToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_RevokeToken.html)¹ |  |  | 
| [GetTokensFromRefreshToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetTokensFromRefreshToken.html)¹ |  |  | 

1 `RevokeToken`並將`GetTokensFromRefreshToken`重新整理字符作為授權參數。重新整理權杖用作授權權杖，並作為目標資源。