AWS Cognito
With this integration you can engage customers with flexible authentication, manage B2B identities, secure machine-to-machine authentication or get role-based access to AWS resources.
Official Websitehttps://aws.amazon.com/es/cognito/
TagsawssecuritySaas
- JavaScript
- Python
Version3.385.0
Documentationhttps://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cognito-idp.html
Pypi packagehttps://pypi.org/project/boto3/
Version1.34.23
Source Codehttps://github.com/boto/boto3
Credential configuration
To configure this credential, you need the Access key ID
and the Secret Access Key
of the Programatic Access
user you want to use. Ensure that this user has the necessary permissions
to access Lambda for proper funtionality. If you need to create the user,
follow the instructions provided here.
In the extra options field, you can include any additional parameters found here.
Here is an example of a filled credential configuration form in YepCode:
AWS Lambda snippets available in YepCode editor
note
The title is the triggering text for YepCode to autocomplete the script.
- JavaScript
- Python
Integration
New integration from credential
const awsCognitoClient = yepcode.integration.awsCognito("credential-slug");
New integration from plain authentication data
const { CognitoIdentityProviderClient } = require("@aws-sdk/client-cognito-identity-provider");
const awsCognitoClient = new CognitoIdentityProviderClient({
credentials: {
accessKeyId: "accessKeyId",
secretAccessKey: "secretAccessKey",
},
});
Create Identify Provider
Create identify provider
const { CreateIdentityProviderCommand } = require('@aws-sdk/client-cognito-identity-provider)
const input = {
UserPoolId: userPoolId,
ProviderName: providerName,
ProviderType: providerType,
ProviderDetails: {
keys: providerDetails,
}
};
const command = new CreateIdentityProviderCommand(input);
const response = await awsCognitoClient.send(command);
Create User Pool
Create user pool
const { CreateUserPoolCommand } = require("@aws-sdk/client-cognito-identity-provider");
const input = {
PoolName: poolName
LambdaConfig: {
CustomSMSSender: {
LambdaVersion: lambdaVersion,
LambdaArn: lambdaArn,
},
CustomEmailSender: {
LambdaVersion: lambdaVersion,
LambdaArn: lambdaArn,
},
},
SmsConfiguration: {
SnsCallerArn: snsCallerArn,
},
UsernameConfiguration: {
CaseSensitive: caseSensitive,
},
AccountRecoverySetting: {
RecoveryMechanisms: [
{
Priority: Number(recoveryMechanismsPriority),
Name: recoveryMechanismsName,
},
],
}
};
const command = new CreateUserPoolCommand(input);
const response = await awsCognitoClient.send(command);
List Identity Providers
List identify providers
const { ListIdentityProvidersCommand } = require("@aws-sdk/client-cognito-identity-provider");
const input = {
UserPoolId: userPoolId
};
const command = new ListIdentityProvidersCommand(input);
const response = await awsCognitoClient.send(command);
for(const provider of response.Providers) {
console.log(provider)
}
Integration
New integration from credential
aws_cognito_client = yepcode.integration.aws_cognito("credential-slug")
New integration from plain authentication data
import boto3
session = boto3.Session(
aws_access_key_id="accessKeyId",
aws_secret_access_key="secretAccessKey",
region_name="region"
)
aws_cognito_client = session.client("cognito")
Create Identify Provider
Create identify provider
response = aws_cognito_client.create_identity_provider(
UserPoolId = userPoolId,
ProviderName = providerName,
ProviderType = providerType,
ProviderDetails = {
keys: providerDetails,
}
)
Create User Pool
Create user pool
response = aws_cognito_client.create_user_pool(
PoolName = poolName
LambdaConfig = {
CustomSMSSender: {
'LambdaVersion': lambdaVersion,
'LambdaArn': lambdaArn,
},
CustomEmailSender: {
'LambdaVersion': lambdaVersion,
'LambdaArn': lambdaArn,
}
},
SmsConfiguration = {
'SnsCallerArn': snsCallerArn
},
UsernameConfiguration = {
'CaseSensitive': caseSensitive
},
AccountRecoverySetting: {
'RecoveryMechanisms': [
{
'Priority': recoveryMechanismsPriority,
'Name': recoveryMechanismsName,
},
]
}
)
List Identity Providers
List identity providers
response = aws_cognito_client.list_identity_providers(
UserPoolId=userPoolId
)
for provider in response['Providers']:
print(provider)