@aws-sdk/client-cognito-identity-provider
Description
AWS SDK for JavaScript CognitoIdentityProvider Client for Node.js, Browser and React Native.
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
link IdP users to native user profiles. Learn more
about the authentication and authorization of federated users at Adding user pool sign-in through a third party and in the User pool federation endpoints and hosted UI reference.
This API reference provides detailed information about API operations and object types
in Amazon Cognito.
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.
-
An administrator who wants to configure user pools, app clients, users,
groups, or other user pool functions.
-
A server-side app, like a web application, that wants to use its Amazon Web Services
privileges to manage, authenticate, or authorize a user.
-
A client-side app, like a mobile app, that wants to make unauthenticated
requests to manage, authenticate, or authorize a user.
For more information, see Using the Amazon Cognito user pools API and user pool endpoints
in the Amazon Cognito Developer Guide.
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 Amazon Cognito user pools service endpoints. The following links can get you started
with the CognitoIdentityProvider
client in other supported Amazon Web Services
SDKs.
To get started with an Amazon Web Services SDK, see Tools to Build on Amazon Web Services. For example actions and scenarios, see Code examples for Amazon Cognito Identity Provider using Amazon Web Services
SDKs.
Installing
To install this package, simply type add or install @aws-sdk/client-cognito-identity-provider
using 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
:
const { CognitoIdentityProviderClient, ListDevicesCommand } = require("@aws-sdk/client-cognito-identity-provider");
import { CognitoIdentityProviderClient, ListDevicesCommand } from "@aws-sdk/client-cognito-identity-provider";
Usage
To send a request, you:
- Initiate client with configuration (e.g. credentials, region).
- Initiate command with input parameters.
- Call
send
operation on client with command object as input. - If you are using a custom http handler, you may call
destroy()
to close open connections.
const client = new CognitoIdentityProviderClient({ region: "REGION" });
const params = {
};
const command = new ListDevicesCommand(params);
Async/await
We recommend using await
operator to wait for the promise returned by send operation as follows:
try {
const data = await client.send(command);
} catch (error) {
} finally {
}
Async-await is clean, concise, intuitive, easy to debug and has better error handling
as compared to using Promise chains or callbacks.
Promises
You can also use Promise chaining
to execute send operation.
client.send(command).then(
(data) => {
},
(error) => {
}
);
Promises can also be called using .catch()
and .finally()
as follows:
client
.send(command)
.then((data) => {
})
.catch((error) => {
})
.finally(() => {
});
Callbacks
We do not recommend using callbacks because of callback hell,
but they are supported by the send operation.
client.send(command, (err, data) => {
});
v2 compatible style
The client can also send requests using v2 compatible style.
However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post
on modular packages in AWS SDK for JavaScript
import * as AWS from "@aws-sdk/client-cognito-identity-provider";
const client = new AWS.CognitoIdentityProvider({ region: "REGION" });
try {
const data = await client.listDevices(params);
} catch (error) {
}
client
.listDevices(params)
.then((data) => {
})
.catch((error) => {
});
client.listDevices(params, (err, data) => {
});
Troubleshooting
When the service returns an exception, the error will include the exception information,
as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
}
Getting Help
Please use these community resources for getting help.
We use the 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)
AddCustomAttributes
Command API Reference / Input / Output
AdminAddUserToGroup
Command API Reference / Input / Output
AdminConfirmSignUp
Command API Reference / Input / Output
AdminCreateUser
Command API Reference / Input / Output
AdminDeleteUser
Command API Reference / Input / Output
AdminDeleteUserAttributes
Command API Reference / Input / Output
AdminDisableProviderForUser
Command API Reference / Input / Output
AdminDisableUser
Command API Reference / Input / Output
AdminEnableUser
Command API Reference / Input / Output
AdminForgetDevice
Command API Reference / Input / Output
AdminGetDevice
Command API Reference / Input / Output
AdminGetUser
Command API Reference / Input / Output
AdminInitiateAuth
Command API Reference / Input / Output
AdminLinkProviderForUser
Command API Reference / Input / Output
AdminListDevices
Command API Reference / Input / Output
AdminListGroupsForUser
Command API Reference / Input / Output
AdminListUserAuthEvents
Command API Reference / Input / Output
AdminRemoveUserFromGroup
Command API Reference / Input / Output
AdminResetUserPassword
Command API Reference / Input / Output
AdminRespondToAuthChallenge
Command API Reference / Input / Output
AdminSetUserMFAPreference
Command API Reference / Input / Output
AdminSetUserPassword
Command API Reference / Input / Output
AdminSetUserSettings
Command API Reference / Input / Output
AdminUpdateAuthEventFeedback
Command API Reference / Input / Output
AdminUpdateDeviceStatus
Command API Reference / Input / Output
AdminUpdateUserAttributes
Command API Reference / Input / Output
AdminUserGlobalSignOut
Command API Reference / Input / Output
AssociateSoftwareToken
Command API Reference / Input / Output
ChangePassword
Command API Reference / Input / Output
ConfirmDevice
Command API Reference / Input / Output
ConfirmForgotPassword
Command API Reference / Input / Output
ConfirmSignUp
Command API Reference / Input / Output
CreateGroup
Command API Reference / Input / Output
CreateIdentityProvider
Command API Reference / Input / Output
CreateResourceServer
Command API Reference / Input / Output
CreateUserImportJob
Command API Reference / Input / Output
CreateUserPool
Command API Reference / Input / Output
CreateUserPoolClient
Command API Reference / Input / Output
CreateUserPoolDomain
Command API Reference / Input / Output
DeleteGroup
Command API Reference / Input / Output
DeleteIdentityProvider
Command API Reference / Input / Output
DeleteResourceServer
Command API Reference / Input / Output
DeleteUser
Command API Reference / Input / Output
DeleteUserAttributes
Command API Reference / Input / Output
DeleteUserPool
Command API Reference / Input / Output
DeleteUserPoolClient
Command API Reference / Input / Output
DeleteUserPoolDomain
Command API Reference / Input / Output
DescribeIdentityProvider
Command API Reference / Input / Output
DescribeResourceServer
Command API Reference / Input / Output
DescribeRiskConfiguration
Command API Reference / Input / Output
DescribeUserImportJob
Command API Reference / Input / Output
DescribeUserPool
Command API Reference / Input / Output
DescribeUserPoolClient
Command API Reference / Input / Output
DescribeUserPoolDomain
Command API Reference / Input / Output
ForgetDevice
Command API Reference / Input / Output
ForgotPassword
Command API Reference / Input / Output
GetCSVHeader
Command API Reference / Input / Output
GetDevice
Command API Reference / Input / Output
GetGroup
Command API Reference / Input / Output
GetIdentityProviderByIdentifier
Command API Reference / Input / Output
GetLogDeliveryConfiguration
Command API Reference / Input / Output
GetSigningCertificate
Command API Reference / Input / Output
GetUICustomization
Command API Reference / Input / Output
GetUser
Command API Reference / Input / Output
GetUserAttributeVerificationCode
Command API Reference / Input / Output
GetUserPoolMfaConfig
Command API Reference / Input / Output
GlobalSignOut
Command API Reference / Input / Output
InitiateAuth
Command API Reference / Input / Output
ListDevices
Command API Reference / Input / Output
ListGroups
Command API Reference / Input / Output
ListIdentityProviders
Command API Reference / Input / Output
ListResourceServers
Command API Reference / Input / Output
ListTagsForResource
Command API Reference / Input / Output
ListUserImportJobs
Command API Reference / Input / Output
ListUserPoolClients
Command API Reference / Input / Output
ListUserPools
Command API Reference / Input / Output
ListUsers
Command API Reference / Input / Output
ListUsersInGroup
Command API Reference / Input / Output
ResendConfirmationCode
Command API Reference / Input / Output
RespondToAuthChallenge
Command API Reference / Input / Output
RevokeToken
Command API Reference / Input / Output
SetLogDeliveryConfiguration
Command API Reference / Input / Output
SetRiskConfiguration
Command API Reference / Input / Output
SetUICustomization
Command API Reference / Input / Output
SetUserMFAPreference
Command API Reference / Input / Output
SetUserPoolMfaConfig
Command API Reference / Input / Output
SetUserSettings
Command API Reference / Input / Output
SignUp
Command API Reference / Input / Output
StartUserImportJob
Command API Reference / Input / Output
StopUserImportJob
Command API Reference / Input / Output
TagResource
Command API Reference / Input / Output
UntagResource
Command API Reference / Input / Output
UpdateAuthEventFeedback
Command API Reference / Input / Output
UpdateDeviceStatus
Command API Reference / Input / Output
UpdateGroup
Command API Reference / Input / Output
UpdateIdentityProvider
Command API Reference / Input / Output
UpdateResourceServer
Command API Reference / Input / Output
UpdateUserAttributes
Command API Reference / Input / Output
UpdateUserPool
Command API Reference / Input / Output
UpdateUserPoolClient
Command API Reference / Input / Output
UpdateUserPoolDomain
Command API Reference / Input / Output
VerifySoftwareToken
Command API Reference / Input / Output
VerifyUserAttribute
Command API Reference / Input / Output