Amazon Cognito: Enroll an Authenticator for TOTP MFA
See more Amazon Cognito Examples
Enable software-token MFA in the pool first. Choose mode=signed_in to enroll with a user access token containing aws.cognito.signin.user.admin, or mode=challenge to continue the MFA_SETUP saved by the sign-in example. Begin obtains a secret and saves it in private cognito-totp.json. Present secret_code securely to the user for manual entry or an otpauth QR code; never place it in ordinary logs. Then set action=verify with the authenticator's code in private totp-input.json.
Checks VerifySoftwareToken.Status=SUCCESS before activating the preference or finishing sign-in. A signed-in enrollment sets SoftwareTokenMfaSettings.Enabled and PreferredMfa. Challenge enrollment uses the successive Session values from AssociateSoftwareToken and VerifySoftwareToken, then RespondToAuthChallenge(MFA_SETUP). Verifying a replacement authenticator can disassociate the old one. If a later step fails after successful verification, inspect the user's MFA/sign-in state rather than repeatedly beginning enrollment.
Uses direct Chilkat.Http requests to the regional Cognito User Pools JSON API. Public app-client operations do not use IAM signing. These examples use a public app client without a client secret; do not add administrative AWS credentials. For a confidential app client, implement the operation-specific SecretHash/SECRET_HASH or ClientSecret requirements on a trusted system.
Create qa_data/cognito/app.json with string fields region (for example us-west-2), user_pool_id, client_id, and account_key (your local account identifier). OAuth examples also require domain, the trusted HTTPS base URL of your Cognito domain, without a trailing slash. The region and user pool must match the app client. These examples use commercial AWS endpoints.
Sample cache/input files contain secrets. Use an access-controlled directory outside web content and source control, separate each local user/account, and serialize operations that modify the same cache. In a real application obtain passwords and codes through private UI instead of leaving them in files. Cache writes retain a .bak copy; protect and remove obsolete backups and challenge files after the flow. Production storage should provide atomic replacement and OS-backed secret protection. Never restore an old refresh token automatically after rotation. These examples do not require a hosted web server.
Checks transport completion, HTTP status, and required response fields before using results. Cognito often reports throttling, invalid codes, and authentication failures as HTTP 400. Present generic sign-in/recovery errors to users; keep detailed diagnostics private. Retry throttled reads with bounded backoff, but reconcile uncertain writes and refresh rotations before repeating them.
AWS documentation 1 | AWS documentation 2 | AWS documentation 3
Chilkat Objective-C Downloads
#import <CkoJsonObject.h>
#import <NSString.h>
#import <CkoStringBuilder.h>
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <CkoFileAccess.h>
#import <CkoDateTime.h>
BOOL success = NO;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
success = NO;
// App settings are trusted configuration. Keep a separate account_key/cache per local user.
CkoJsonObject *app = [[CkoJsonObject alloc] init];
app.Strict = YES;
success = [app LoadFile: @"qa_data/cognito/app.json"];
if (success != YES) {
NSLog(@"%@",@"Could not load Cognito app settings.");
return;
}
if (([[app JsonTypeOf: @"region"] intValue] != 1) || ([app StringOf: @"region"] == @"")) {
NSLog(@"%@",@"Missing or invalid region.");
return;
}
if (([[app JsonTypeOf: @"user_pool_id"] intValue] != 1) || ([app StringOf: @"user_pool_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid user_pool_id.");
return;
}
if (([[app JsonTypeOf: @"client_id"] intValue] != 1) || ([app StringOf: @"client_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid client_id.");
return;
}
if (([[app JsonTypeOf: @"account_key"] intValue] != 1) || ([app StringOf: @"account_key"] == @"")) {
NSLog(@"%@",@"Missing or invalid account_key.");
return;
}
NSString *clientId = [app StringOf: @"client_id"];
CkoStringBuilder *endpoint = [[CkoStringBuilder alloc] init];
[endpoint Append: @"https://cognito-idp."];
[endpoint Append: [app StringOf: @"region"]];
[endpoint Append: @".amazonaws.com/"];
CkoHttp *http = [[CkoHttp alloc] init];
http.RequireSslCertVerify = YES;
http.FollowRedirects = NO;
http.ConnectTimeout = [NSNumber numberWithInt:20];
http.ReadTimeout = [NSNumber numberWithInt:60];
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
CkoJsonObject *body = [[CkoJsonObject alloc] init];
CkoJsonObject *result = [[CkoJsonObject alloc] init];
result.Strict = YES;
NSString *action = @"begin";
NSString *mode = @"signed_in";
if ((action != @"begin") && (action != @"verify")) {
NSLog(@"%@",@"Choose begin or verify.");
return;
}
if ((mode != @"signed_in") && (mode != @"challenge")) {
NSLog(@"%@",@"Choose signed_in or challenge.");
return;
}
NSString *username = @"";
CkoJsonObject *credential = [[CkoJsonObject alloc] init];
if (mode == @"signed_in") {
success = [credential LoadFile: @"qa_data/tokens/cognito-user.json"];
if (success != YES) {
NSLog(@"%@",@"Could not load user tokens.");
return;
}
if (([[credential JsonTypeOf: @"client_id"] intValue] != 1) || ([credential StringOf: @"client_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid client_id.");
return;
}
if ([credential StringOf: @"client_id"] != [app StringOf: @"client_id"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[credential JsonTypeOf: @"user_pool_id"] intValue] != 1) || ([credential StringOf: @"user_pool_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid user_pool_id.");
return;
}
if ([credential StringOf: @"user_pool_id"] != [app StringOf: @"user_pool_id"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[credential JsonTypeOf: @"account_key"] intValue] != 1) || ([credential StringOf: @"account_key"] == @"")) {
NSLog(@"%@",@"Missing or invalid account_key.");
return;
}
if ([credential StringOf: @"account_key"] != [app StringOf: @"account_key"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[credential JsonTypeOf: @"access_token"] intValue] != 1) || ([credential StringOf: @"access_token"] == @"")) {
NSLog(@"%@",@"Missing or invalid access_token.");
return;
}
}
else {
success = [credential LoadFile: @"qa_data/tokens/cognito-challenge.json"];
if (success != YES) {
NSLog(@"%@",@"Could not load the MFA_SETUP challenge.");
return;
}
if (([[credential JsonTypeOf: @"client_id"] intValue] != 1) || ([credential StringOf: @"client_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid client_id.");
return;
}
if ([credential StringOf: @"client_id"] != [app StringOf: @"client_id"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[credential JsonTypeOf: @"user_pool_id"] intValue] != 1) || ([credential StringOf: @"user_pool_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid user_pool_id.");
return;
}
if ([credential StringOf: @"user_pool_id"] != [app StringOf: @"user_pool_id"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[credential JsonTypeOf: @"account_key"] intValue] != 1) || ([credential StringOf: @"account_key"] == @"")) {
NSLog(@"%@",@"Missing or invalid account_key.");
return;
}
if ([credential StringOf: @"account_key"] != [app StringOf: @"account_key"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[credential JsonTypeOf: @"Session"] intValue] != 1) || ([credential StringOf: @"Session"] == @"")) {
NSLog(@"%@",@"Missing or invalid Session.");
return;
}
if (([[credential JsonTypeOf: @"username"] intValue] != 1) || ([credential StringOf: @"username"] == @"")) {
NSLog(@"%@",@"Missing or invalid username.");
return;
}
if ([credential StringOf: @"ChallengeName"] != @"MFA_SETUP") {
NSLog(@"%@",@"Expected an MFA_SETUP challenge.");
return;
}
username = [credential StringOf: @"username"];
}
if (action == @"begin") {
if (mode == @"signed_in") {
[body UpdateString: @"AccessToken" value: [credential StringOf: @"access_token"]];
}
else {
[body UpdateString: @"Session" value: [credential StringOf: @"Session"]];
}
[http SetRequestHeader: @"X-Amz-Target" value: @"AWSCognitoIdentityProviderService.AssociateSoftwareToken"];
success = [http HttpJson: @"POST" url: [endpoint GetAsString] json: body contentType: @"application/x-amz-json-1.0" response: resp];
if ([resp.StatusCode intValue] != 200) {
NSLog(@"%@%d",@"HTTP status: ",[resp.StatusCode intValue]);
success = [result Load: resp.BodyStr];
if (success == YES) {
NSLog(@"%@%@",@"Error type: ",[result StringOf: @"__type"]);
NSLog(@"%@%@",@"OAuth error: ",[result StringOf: @"error"]);
}
// Inspect detailed diagnostics privately. Do not log passwords, sessions, or tokens.
return;
}
if (success != YES) {
NSLog(@"%@",@"The HTTP exchange did not complete.");
return;
}
success = [result Load: resp.BodyStr];
if (success != YES) {
NSLog(@"%@",@"Expected a JSON response.");
return;
}
if (([[result JsonTypeOf: @"SecretCode"] intValue] != 1) || ([result StringOf: @"SecretCode"] == @"")) {
NSLog(@"%@",@"Missing or invalid SecretCode.");
return;
}
CkoJsonObject *newEnrollment = [[CkoJsonObject alloc] init];
[newEnrollment UpdateString: @"secret_code" value: [result StringOf: @"SecretCode"]];
[newEnrollment UpdateString: @"mode" value: mode];
[newEnrollment UpdateString: @"username" value: username];
if (mode == @"challenge") {
if (([[result JsonTypeOf: @"Session"] intValue] != 1) || ([result StringOf: @"Session"] == @"")) {
NSLog(@"%@",@"Missing or invalid Session.");
return;
}
[newEnrollment UpdateString: @"session" value: [result StringOf: @"Session"]];
// Bind enrollment to this precise challenge, not just the account.
[newEnrollment UpdateString: @"original_session" value: [credential StringOf: @"Session"]];
}
[newEnrollment UpdateString: @"client_id" value: [app StringOf: @"client_id"]];
[newEnrollment UpdateString: @"user_pool_id" value: [app StringOf: @"user_pool_id"]];
[newEnrollment UpdateString: @"account_key" value: [app StringOf: @"account_key"]];
CkoFileAccess *newEnrollmentTOTPenrollment = [[CkoFileAccess alloc] init];
success = [newEnrollmentTOTPenrollment DirEnsureExists: @"qa_data/tokens"];
if (success != YES) {
NSLog(@"%@",@"Could not create the private cache directory.");
return;
}
if ([newEnrollmentTOTPenrollment FileExists: @"qa_data/tokens/cognito-totp.json"] == YES) {
success = [newEnrollmentTOTPenrollment FileCopy: @"qa_data/tokens/cognito-totp.json" newPath: @"qa_data/tokens/cognito-totp.json.bak" failIfExists: NO];
if (success != YES) {
NSLog(@"%@",@"Could not back up the existing cache.");
return;
}
}
success = [newEnrollment WriteFile: @"qa_data/tokens/cognito-totp.json"];
if (success != YES) {
NSLog(@"%@",@"Could not save TOTP enrollment; preserve any previous backup.");
return;
}
NSLog(@"%@",@"Enrollment saved. Present secret_code privately in your authenticator setup UI.");
// This secret can generate future OTPs. Never log it or email it.
return;
}
CkoJsonObject *enrollment = [[CkoJsonObject alloc] init];
enrollment.Strict = YES;
success = [enrollment LoadFile: @"qa_data/tokens/cognito-totp.json"];
if (success != YES) {
NSLog(@"%@",@"Could not load qa_data/tokens/cognito-totp.json.");
return;
}
if (([[enrollment JsonTypeOf: @"client_id"] intValue] != 1) || ([enrollment StringOf: @"client_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid client_id.");
return;
}
if ([enrollment StringOf: @"client_id"] != [app StringOf: @"client_id"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[enrollment JsonTypeOf: @"user_pool_id"] intValue] != 1) || ([enrollment StringOf: @"user_pool_id"] == @"")) {
NSLog(@"%@",@"Missing or invalid user_pool_id.");
return;
}
if ([enrollment StringOf: @"user_pool_id"] != [app StringOf: @"user_pool_id"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if (([[enrollment JsonTypeOf: @"account_key"] intValue] != 1) || ([enrollment StringOf: @"account_key"] == @"")) {
NSLog(@"%@",@"Missing or invalid account_key.");
return;
}
if ([enrollment StringOf: @"account_key"] != [app StringOf: @"account_key"]) {
NSLog(@"%@",@"Saved data belongs to another client, pool, or local account.");
return;
}
if ([enrollment StringOf: @"mode"] != mode) {
NSLog(@"%@",@"Enrollment mode mismatch.");
return;
}
CkoJsonObject *input = [[CkoJsonObject alloc] init];
input.Strict = YES;
success = [input LoadFile: @"qa_data/cognito/totp-input.json"];
if (success != YES) {
NSLog(@"%@",@"Could not load qa_data/cognito/totp-input.json.");
return;
}
if (([[input JsonTypeOf: @"code"] intValue] != 1) || ([input StringOf: @"code"] == @"")) {
NSLog(@"%@",@"Missing or invalid code.");
return;
}
// Enter a fresh six-digit code from the authenticator; preserve leading zeroes.
[body UpdateString: @"UserCode" value: [input StringOf: @"code"]];
[body UpdateString: @"FriendlyDeviceName" value: @"Authenticator"];
if (mode == @"signed_in") {
[body UpdateString: @"AccessToken" value: [credential StringOf: @"access_token"]];
}
else {
if (([[enrollment JsonTypeOf: @"session"] intValue] != 1) || ([enrollment StringOf: @"session"] == @"")) {
NSLog(@"%@",@"Missing or invalid session.");
return;
}
if ([enrollment StringOf: @"original_session"] != [credential StringOf: @"Session"]) {
NSLog(@"%@",@"Enrollment belongs to another sign-in challenge.");
return;
}
[body UpdateString: @"Session" value: [enrollment StringOf: @"session"]];
}
[http SetRequestHeader: @"X-Amz-Target" value: @"AWSCognitoIdentityProviderService.VerifySoftwareToken"];
success = [http HttpJson: @"POST" url: [endpoint GetAsString] json: body contentType: @"application/x-amz-json-1.0" response: resp];
if ([resp.StatusCode intValue] != 200) {
NSLog(@"%@%d",@"HTTP status: ",[resp.StatusCode intValue]);
success = [result Load: resp.BodyStr];
if (success == YES) {
NSLog(@"%@%@",@"Error type: ",[result StringOf: @"__type"]);
NSLog(@"%@%@",@"OAuth error: ",[result StringOf: @"error"]);
}
// Inspect detailed diagnostics privately. Do not log passwords, sessions, or tokens.
return;
}
if (success != YES) {
NSLog(@"%@",@"The HTTP exchange did not complete.");
return;
}
success = [result Load: resp.BodyStr];
if (success != YES) {
NSLog(@"%@",@"Expected a JSON response.");
return;
}
if ([result StringOf: @"Status"] != @"SUCCESS") {
NSLog(@"%@",@"Authenticator verification did not succeed; do not enable it.");
return;
}
// Verification succeeded. Discard the enrollment secret and its backup.
CkoFileAccess *removeEnrollment = [[CkoFileAccess alloc] init];
[removeEnrollment FileDelete: @"qa_data/tokens/cognito-totp.json"];
if ([removeEnrollment FileExists: @"qa_data/tokens/cognito-totp.json.bak"] == YES) {
[removeEnrollment FileDelete: @"qa_data/tokens/cognito-totp.json.bak"];
}
success = [body Load: @"{}"];
if (success != YES) {
NSLog(@"%@",@"Could not reset the request body.");
return;
}
if (mode == @"signed_in") {
[body UpdateString: @"AccessToken" value: [credential StringOf: @"access_token"]];
[body UpdateBool: @"SoftwareTokenMfaSettings.Enabled" value: YES];
[body UpdateBool: @"SoftwareTokenMfaSettings.PreferredMfa" value: YES];
[http SetRequestHeader: @"X-Amz-Target" value: @"AWSCognitoIdentityProviderService.SetUserMFAPreference"];
success = [http HttpJson: @"POST" url: [endpoint GetAsString] json: body contentType: @"application/x-amz-json-1.0" response: resp];
if ([resp.StatusCode intValue] != 200) {
NSLog(@"%@%d",@"HTTP status: ",[resp.StatusCode intValue]);
success = [result Load: resp.BodyStr];
if (success == YES) {
NSLog(@"%@%@",@"Error type: ",[result StringOf: @"__type"]);
NSLog(@"%@%@",@"OAuth error: ",[result StringOf: @"error"]);
}
// Inspect detailed diagnostics privately. Do not log passwords, sessions, or tokens.
return;
}
if (success != YES) {
NSLog(@"%@",@"The HTTP exchange did not complete.");
return;
}
NSLog(@"%@",@"Authenticator verified and set as the preferred MFA method.");
return;
}
if (([[result JsonTypeOf: @"Session"] intValue] != 1) || ([result StringOf: @"Session"] == @"")) {
NSLog(@"%@",@"Missing or invalid Session.");
return;
}
// Submit the NEW Session returned by VerifySoftwareToken, not the earlier one.
[body UpdateString: @"ClientId" value: clientId];
[body UpdateString: @"ChallengeName" value: @"MFA_SETUP"];
[body UpdateString: @"Session" value: [result StringOf: @"Session"]];
[body UpdateString: @"ChallengeResponses.USERNAME" value: username];
[http SetRequestHeader: @"X-Amz-Target" value: @"AWSCognitoIdentityProviderService.RespondToAuthChallenge"];
success = [http HttpJson: @"POST" url: [endpoint GetAsString] json: body contentType: @"application/x-amz-json-1.0" response: resp];
if ([resp.StatusCode intValue] != 200) {
NSLog(@"%@%d",@"HTTP status: ",[resp.StatusCode intValue]);
success = [result Load: resp.BodyStr];
if (success == YES) {
NSLog(@"%@%@",@"Error type: ",[result StringOf: @"__type"]);
NSLog(@"%@%@",@"OAuth error: ",[result StringOf: @"error"]);
}
// Inspect detailed diagnostics privately. Do not log passwords, sessions, or tokens.
return;
}
if (success != YES) {
NSLog(@"%@",@"The HTTP exchange did not complete.");
return;
}
success = [result Load: resp.BodyStr];
if (success != YES) {
NSLog(@"%@",@"Expected a JSON response.");
return;
}
if ([[result JsonTypeOf: @"AuthenticationResult"] intValue] == 3) {
CkoJsonObject *token = [[CkoJsonObject alloc] init];
[token UpdateString: @"access_token" value: [result StringOf: @"AuthenticationResult.AccessToken"]];
[token UpdateString: @"id_token" value: [result StringOf: @"AuthenticationResult.IdToken"]];
[token UpdateString: @"token_type" value: [result StringOf: @"AuthenticationResult.TokenType"]];
[token UpdateInt: @"expires_in" value: [result IntOf: @"AuthenticationResult.ExpiresIn"]];
if ([result HasMember: @"AuthenticationResult.RefreshToken"] == YES) {
[token UpdateString: @"refresh_token" value: [result StringOf: @"AuthenticationResult.RefreshToken"]];
}
if (([[token JsonTypeOf: @"access_token"] intValue] != 1) || ([token StringOf: @"access_token"] == @"")) {
NSLog(@"%@",@"Missing or invalid access_token.");
return;
}
if (([[token JsonTypeOf: @"id_token"] intValue] != 1) || ([token StringOf: @"id_token"] == @"")) {
NSLog(@"%@",@"Missing or invalid id_token.");
return;
}
if (([[token JsonTypeOf: @"expires_in"] intValue] != 2) || ([[token IntOf: @"expires_in"] intValue] <= 0)) {
NSLog(@"%@",@"Expected a positive token lifetime.");
return;
}
if ([token StringOf: @"token_type"] != @"Bearer") {
NSLog(@"%@",@"Expected Bearer tokens.");
return;
}
if (([[token JsonTypeOf: @"refresh_token"] intValue] != 1) || ([token StringOf: @"refresh_token"] == @"")) {
NSLog(@"%@",@"Missing or invalid refresh_token.");
return;
}
[token UpdateString: @"client_id" value: [app StringOf: @"client_id"]];
[token UpdateString: @"user_pool_id" value: [app StringOf: @"user_pool_id"]];
[token UpdateString: @"account_key" value: [app StringOf: @"account_key"]];
CkoDateTime *obtained = [[CkoDateTime alloc] init];
success = [obtained SetFromCurrentSystemTime];
if (success != YES) {
NSLog(@"%@",@"Could not get the acquisition time.");
return;
}
[token UpdateString: @"obtained_at" value: [obtained GetAsTimestamp: NO]];
CkoFileAccess *tokenusertokens = [[CkoFileAccess alloc] init];
success = [tokenusertokens DirEnsureExists: @"qa_data/tokens"];
if (success != YES) {
NSLog(@"%@",@"Could not create the private cache directory.");
return;
}
if ([tokenusertokens FileExists: @"qa_data/tokens/cognito-user.json"] == YES) {
success = [tokenusertokens FileCopy: @"qa_data/tokens/cognito-user.json" newPath: @"qa_data/tokens/cognito-user.json.bak" failIfExists: NO];
if (success != YES) {
NSLog(@"%@",@"Could not back up the existing cache.");
return;
}
}
success = [token WriteFile: @"qa_data/tokens/cognito-user.json"];
if (success != YES) {
NSLog(@"%@",@"Could not save user tokens; preserve any previous backup.");
return;
}
// A completed flow no longer needs its short-lived challenge session.
CkoFileAccess *cleanup = [[CkoFileAccess alloc] init];
if ([cleanup FileExists: @"qa_data/tokens/cognito-challenge.json"] == YES) {
[cleanup FileDelete: @"qa_data/tokens/cognito-challenge.json"];
}
NSLog(@"%@",@"Sign-in completed; private token cache saved.");
return;
}
if (([[result JsonTypeOf: @"ChallengeName"] intValue] != 1) || ([result StringOf: @"ChallengeName"] == @"")) {
NSLog(@"%@",@"Missing or invalid ChallengeName.");
return;
}
if (([[result JsonTypeOf: @"Session"] intValue] != 1) || ([result StringOf: @"Session"] == @"")) {
NSLog(@"%@",@"Missing or invalid Session.");
return;
}
// ChallengeParameters may provide the canonical username after alias-based sign-in.
if (([[result JsonTypeOf: @"ChallengeParameters.USER_ID_FOR_SRP"] intValue] == 1) && ([result StringOf: @"ChallengeParameters.USER_ID_FOR_SRP"] != @"")) {
username = [result StringOf: @"ChallengeParameters.USER_ID_FOR_SRP"];
}
if (([[result JsonTypeOf: @"ChallengeParameters.USERNAME"] intValue] == 1) && ([result StringOf: @"ChallengeParameters.USERNAME"] != @"")) {
username = [result StringOf: @"ChallengeParameters.USERNAME"];
}
[result UpdateString: @"username" value: username];
[result UpdateString: @"client_id" value: [app StringOf: @"client_id"]];
[result UpdateString: @"user_pool_id" value: [app StringOf: @"user_pool_id"]];
[result UpdateString: @"account_key" value: [app StringOf: @"account_key"]];
CkoFileAccess *resultauthenticationchallenge = [[CkoFileAccess alloc] init];
success = [resultauthenticationchallenge DirEnsureExists: @"qa_data/tokens"];
if (success != YES) {
NSLog(@"%@",@"Could not create the private cache directory.");
return;
}
if ([resultauthenticationchallenge FileExists: @"qa_data/tokens/cognito-challenge.json"] == YES) {
success = [resultauthenticationchallenge FileCopy: @"qa_data/tokens/cognito-challenge.json" newPath: @"qa_data/tokens/cognito-challenge.json.bak" failIfExists: NO];
if (success != YES) {
NSLog(@"%@",@"Could not back up the existing cache.");
return;
}
}
success = [result WriteFile: @"qa_data/tokens/cognito-challenge.json"];
if (success != YES) {
NSLog(@"%@",@"Could not save authentication challenge; preserve any previous backup.");
return;
}
NSLog(@"%@%@",@"Further authentication required: ",[result StringOf: @"ChallengeName"]);
// Collect the requested input in your application's UI; never print the Session value.