4.2.2 Using user pools with Bayun AWSS3 wrapper 'SecureAuthentication'

Here are the details about registering, confirming, and authenticating users using AWSS3 wrapper. User Registration, SignUp Confirmation, SignIn, SignOut needs to be done with SecureAuthentication instance.

Creating an AWSCognitoIdentityUserPool Object

The following procedure describes how to create an AWSCognitoIdentityUserPool object to interact with.

1. Set up your service config

There is no change in setting up Service Config and is same as using standard AWS Mobile SDK.

AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil];

2. Create a user pool configuration.

There is no change in creating user pool configuration and is same as using standard AWS Mobile SDK.

//create a pool
AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:@"CLIENT_ID" clientSecret:@"CLIENT_SECRET" poolId:@"USER_POOL_ID"];

[AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:@"UserPool"];

AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"];

Register a User

Use SecureAuthentication's signUp:username:password:userAttributes:userAttributes:validationData:withBlock: method to register a new user instead of relying on standard AWS Mobile SDK's signUp method.

Confirm Signup

Confirm a users' sign up with the confirmation code using SecureAuthentication's confirmSignUpForUser:confirmationCode:forceAliasCreation:withBlock: method.

Sign in a User

Use SecureAuthentication's signInPool:username:password:withBlock: method to get a session username and password.

Signout a user

Use SecureAuthentication's signout method to clear all tokens.

Last updated

Was this helpful?