What is @aws-sdk/client-sso?
The @aws-sdk/client-sso package is a client library for AWS Single Sign-On (SSO) that allows developers to interact with the AWS SSO service programmatically. It provides methods to manage SSO access to AWS accounts and applications, retrieve user credentials, and manage SSO sessions.
What are @aws-sdk/client-sso's main functionalities?
GetRoleCredentials
This feature allows you to retrieve the temporary credentials for an AWS role that the user has access to through AWS SSO.
const { SSOClient, GetRoleCredentialsCommand } = require('@aws-sdk/client-sso');
const client = new SSOClient({ region: 'us-west-2' });
const command = new GetRoleCredentialsCommand({
accountId: '123456789012',
roleName: 'MyRoleName',
accessToken: 'myAccessToken'
});
client.send(command).then((data) => {
console.log(data.roleCredentials);
});
ListAccounts
This feature lists all AWS accounts assigned to the user through AWS SSO.
const { SSOClient, ListAccountsCommand } = require('@aws-sdk/client-sso');
const client = new SSOClient({ region: 'us-west-2' });
const command = new ListAccountsCommand({
accessToken: 'myAccessToken'
});
client.send(command).then((data) => {
console.log(data.accountList);
});
Logout
This feature logs the user out of all AWS SSO sessions.
const { SSOClient, LogoutCommand } = require('@aws-sdk/client-sso');
const client = new SSOClient({ region: 'us-west-2' });
const command = new LogoutCommand({
accessToken: 'myAccessToken'
});
client.send(command).then(() => {
console.log('Successfully logged out');
});
Other packages similar to @aws-sdk/client-sso
aws-sdk
The 'aws-sdk' package is the older version of the AWS SDK for JavaScript. It provides a comprehensive feature set for interacting with AWS services, including AWS SSO. However, it is not as modular as the newer '@aws-sdk/client-sso' and might result in larger bundle sizes if only a subset of services is needed.
aws-amplify
The 'aws-amplify' package is a library designed to help build scalable full-stack applications on AWS. It includes authentication features through Amazon Cognito, which can be integrated with AWS SSO for user sign-in and access control. It is a higher-level abstraction compared to '@aws-sdk/client-sso' and includes a broader set of features beyond AWS service interaction.