Back to Aws Sdk Js V3

@aws-sdk/client-cognito-identity-provider

clients/client-cognito-identity-provider/README.md

3.1044.071.6 KB
Original Source
<!-- generated file, do not edit directly -->

@aws-sdk/client-cognito-identity-provider

Description

AWS SDK for JavaScript CognitoIdentityProvider Client for Node.js, Browser and React Native.

<p>With the Amazon Cognito user pools API, you can configure user pools and authenticate users. To authenticate users from third-party identity providers (IdPs) in this API, you can <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-identity-federation-consolidate-users.html">link IdP users to native user profiles</a>. Learn more about the authentication and authorization of federated users at <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-identity-federation.html">Adding user pool sign-in through a third party</a> and in the <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html">User pool federation endpoints and managed login reference</a>.</p> <p>This API reference provides detailed information about API operations and object types in Amazon Cognito.</p> <p>Along with resource management operations, the Amazon Cognito user pools API includes classes of operations and authorization models for client-side and server-side authentication of users. You can interact with operations in the Amazon Cognito user pools API as any of the following subjects.</p> <ol> <li> <p>An administrator who wants to configure user pools, app clients, users, groups, or other user pool functions.</p> </li> <li> <p>A server-side app, like a web application, that wants to use its Amazon Web Services privileges to manage, authenticate, or authorize a user.</p> </li> <li> <p>A client-side app, like a mobile app, that wants to make unauthenticated requests to manage, authenticate, or authorize a user.</p> </li> </ol> <p>For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flows-public-server-side.html#user-pools-API-operations">Understanding API, OIDC, and managed login pages authentication</a> in the <i>Amazon Cognito Developer Guide</i>.</p> <p>With your Amazon Web Services SDK, you can build the logic to support operational flows in every use case for this API. You can also make direct REST API requests to <a href="https://docs.aws.amazon.com/general/latest/gr/cognito_identity.html#cognito_identity_your_user_pools_region">Amazon Cognito user pools service endpoints</a>. The following links can get you started with the <code>CognitoIdentityProvider</code> client in supported Amazon Web Services SDKs.</p> <p>To get started with an Amazon Web Services SDK, see <a href="http://aws.amazon.com/developer/tools/">Tools to Build on Amazon Web Services</a>. For example actions and scenarios, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/service_code_examples_cognito-identity-provider.html">Code examples for Amazon Cognito Identity Provider using Amazon Web Services SDKs</a>.</p>

Installing

To install this package, use the CLI of your favorite package manager:

  • npm install @aws-sdk/client-cognito-identity-provider
  • yarn add @aws-sdk/client-cognito-identity-provider
  • pnpm add @aws-sdk/client-cognito-identity-provider

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the CognitoIdentityProviderClient and the commands you need, for example ListDevicesCommand:

js
// ES5 example
const { CognitoIdentityProviderClient, ListDevicesCommand } = require("@aws-sdk/client-cognito-identity-provider");
ts
// ES6+ example
import { CognitoIdentityProviderClient, ListDevicesCommand } from "@aws-sdk/client-cognito-identity-provider";

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
js
const client = new CognitoIdentityProviderClient({ region: "REGION" });

const params = { /** input parameters */ };
const command = new ListDevicesCommand(params);

Async/await

We recommend using the await operator to wait for the promise returned by send operation as follows:

js
// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Promises

You can also use Promise chaining.

js
client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

CognitoIdentityProvider extends CognitoIdentityProviderClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (CognitoIdentityProviderClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { CognitoIdentityProvider } from "@aws-sdk/client-cognito-identity-provider";

const client = new CognitoIdentityProvider({ region: "REGION" });

// async/await.
try {
  const data = await client.listDevices(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .listDevices(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks (not recommended).
client.listDevices(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

js
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-cognito-identity-provider package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

<details> <summary> AddCustomAttributes </summary>

Command API Reference / Input / Output

</details> <details> <summary> AddUserPoolClientSecret </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminAddUserToGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminConfirmSignUp </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminCreateUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminDeleteUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminDeleteUserAttributes </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminDisableProviderForUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminDisableUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminEnableUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminForgetDevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminGetDevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminGetUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminInitiateAuth </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminLinkProviderForUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminListDevices </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminListGroupsForUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminListUserAuthEvents </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminRemoveUserFromGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminResetUserPassword </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminRespondToAuthChallenge </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminSetUserMFAPreference </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminSetUserPassword </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminSetUserSettings </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminUpdateAuthEventFeedback </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminUpdateDeviceStatus </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminUpdateUserAttributes </summary>

Command API Reference / Input / Output

</details> <details> <summary> AdminUserGlobalSignOut </summary>

Command API Reference / Input / Output

</details> <details> <summary> AssociateSoftwareToken </summary>

Command API Reference / Input / Output

</details> <details> <summary> ChangePassword </summary>

Command API Reference / Input / Output

</details> <details> <summary> CompleteWebAuthnRegistration </summary>

Command API Reference / Input / Output

</details> <details> <summary> ConfirmDevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> ConfirmForgotPassword </summary>

Command API Reference / Input / Output

</details> <details> <summary> ConfirmSignUp </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateIdentityProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateManagedLoginBranding </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateResourceServer </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateTerms </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateUserImportJob </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateUserPool </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateUserPoolClient </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateUserPoolDomain </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteIdentityProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteManagedLoginBranding </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteResourceServer </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteTerms </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUserAttributes </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUserPool </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUserPoolClient </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUserPoolClientSecret </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUserPoolDomain </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteWebAuthnCredential </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeIdentityProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeManagedLoginBranding </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeManagedLoginBrandingByClient </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeResourceServer </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeRiskConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeTerms </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeUserImportJob </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeUserPool </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeUserPoolClient </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeUserPoolDomain </summary>

Command API Reference / Input / Output

</details> <details> <summary> ForgetDevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> ForgotPassword </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetCSVHeader </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetDevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetIdentityProviderByIdentifier </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetLogDeliveryConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetSigningCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetTokensFromRefreshToken </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetUICustomization </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetUserAttributeVerificationCode </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetUserAuthFactors </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetUserPoolMfaConfig </summary>

Command API Reference / Input / Output

</details> <details> <summary> GlobalSignOut </summary>

Command API Reference / Input / Output

</details> <details> <summary> InitiateAuth </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListDevices </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListGroups </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListIdentityProviders </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListResourceServers </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTagsForResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTerms </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUserImportJobs </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUserPoolClients </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUserPoolClientSecrets </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUserPools </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUsers </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUsersInGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListWebAuthnCredentials </summary>

Command API Reference / Input / Output

</details> <details> <summary> ResendConfirmationCode </summary>

Command API Reference / Input / Output

</details> <details> <summary> RespondToAuthChallenge </summary>

Command API Reference / Input / Output

</details> <details> <summary> RevokeToken </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetLogDeliveryConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetRiskConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetUICustomization </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetUserMFAPreference </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetUserPoolMfaConfig </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetUserSettings </summary>

Command API Reference / Input / Output

</details> <details> <summary> SignUp </summary>

Command API Reference / Input / Output

</details> <details> <summary> StartUserImportJob </summary>

Command API Reference / Input / Output

</details> <details> <summary> StartWebAuthnRegistration </summary>

Command API Reference / Input / Output

</details> <details> <summary> StopUserImportJob </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateAuthEventFeedback </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateDeviceStatus </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateIdentityProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateManagedLoginBranding </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateResourceServer </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateTerms </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateUserAttributes </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateUserPool </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateUserPoolClient </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateUserPoolDomain </summary>

Command API Reference / Input / Output

</details> <details> <summary> VerifySoftwareToken </summary>

Command API Reference / Input / Output

</details> <details> <summary> VerifyUserAttribute </summary>

Command API Reference / Input / Output

</details>