authentication using aws cognito code example
Example 1: cognito aws
// Add 'aws-amplify' library into your application
// Configure Auth category with your Amazon Cognito credentials
Amplify.configure({
Auth: {
identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX', // Amazon Cognito Identity Pool ID
region: 'XX-XXXX-X', // Amazon Cognito Region
}
});
// Call Auth.signIn with user credentials
Auth.signIn(username, password)
.then(user => console.log(user))
.catch(err => console.log(err));
Example 2: cognito authentication in AWS using C#
. . .
using Amazon.CognitoIdentityProvider;
using Amazon.CognitoIdentityProvider.Model;
public class CognitoUserStore : IUserStore<CognitoUser>,
IUserLockoutStore<CognitoUser, string>,
IUserTwoFactorStore<CognitoUser, string>
{
private readonly AmazonCognitoIdentityProviderClient _client =
new AmazonCognitoIdentityProviderClient();
private readonly string _clientId = ConfigurationManager.AppSettings["CLIENT_ID"];
private readonly string _poolId = ConfigurationManager.AppSettings["USERPOOL_ID"];
. . .
}