What is @aws-sdk/client-sso-oidc?
The @aws-sdk/client-sso-oidc package is a client library for AWS Single Sign-On OIDC (OpenID Connect) service. It allows developers to programmatically interact with the AWS SSO OIDC service to create and manage authentication tokens for federated users accessing AWS resources.
What are @aws-sdk/client-sso-oidc's main functionalities?
CreateToken
This feature allows you to create a new token for a registered client. This is typically used to get an access token using a refresh token.
const { SSOOIDCClient, CreateTokenCommand } = require('@aws-sdk/client-sso-oidc');
const client = new SSOOIDCClient({ region: 'us-west-2' });
const command = new CreateTokenCommand({
clientId: 'exampleClientId',
clientSecret: 'exampleClientSecret',
grantType: 'refresh_token',
refreshToken: 'exampleRefreshToken',
scope: ['aws.cognito.signin.user.admin']
});
client.send(command).then((response) => {
console.log(response);
}).catch((error) => {
console.error(error);
});
RegisterClient
This feature is used to register a new client with AWS SSO OIDC service. It is the first step in setting up the OIDC relationship.
const { SSOOIDCClient, RegisterClientCommand } = require('@aws-sdk/client-sso-oidc');
const client = new SSOOIDCClient({ region: 'us-west-2' });
const command = new RegisterClientCommand({
clientName: 'exampleClientName',
clientType: 'public',
scopes: ['aws.cognito.signin.user.admin']
});
client.send(command).then((response) => {
console.log(response);
}).catch((error) => {
console.error(error);
});
StartDeviceAuthorization
This feature initiates the device authorization flow by getting a device code that can be used by end-users to authorize their device.
const { SSOOIDCClient, StartDeviceAuthorizationCommand } = require('@aws-sdk/client-sso-oidc');
const client = new SSOOIDCClient({ region: 'us-west-2' });
const command = new StartDeviceAuthorizationCommand({
clientId: 'exampleClientId',
clientSecret: 'exampleClientSecret',
startUrl: 'https://my-sso-start-url.example.com'
});
client.send(command).then((response) => {
console.log(response);
}).catch((error) => {
console.error(error);
});
Other packages similar to @aws-sdk/client-sso-oidc
openid-client
The openid-client package is a server-side library that allows you to interact with OpenID Connect (OIDC) providers. It is more generic than @aws-sdk/client-sso-oidc and can be used with any OIDC-compliant provider, not just AWS SSO.
passport-azure-ad
This package is a collection of Passport strategies to help you integrate with Azure Active Directory. It is similar to @aws-sdk/client-sso-oidc in that it deals with OIDC, but it is specifically tailored for Azure AD rather than AWS SSO.
amazon-cognito-identity-js
While not strictly for OIDC, amazon-cognito-identity-js is an AWS library that allows you to work with Amazon Cognito, which can act as an OIDC identity provider. It provides user authentication and access control features similar to what you might use @aws-sdk/client-sso-oidc for, but it is specific to Amazon Cognito.