@@ -43,6 +43,96 @@ import iosConfirmSignInTotpMFA from '/src/fragments/lib/auth/ios/signin_next_ste
43
43
44
44
<Fragments fragments = { { swift: iosConfirmSignInTotpMFA }} />
45
45
46
+ <InlineFilter filters = { [' android' ]} >
47
+
48
+ <BlockSwitcher >
49
+ <Block name = " Java" >
50
+
51
+ ``` java
52
+ Amplify . Auth . confirmSignIn(
53
+ " TOTP confirmation code" ,
54
+ result - > {
55
+ if (result. isSignedIn()) {
56
+ Log . i(" AuthQuickstart" , " Confirm signIn succeeded" );
57
+ } else {
58
+ Log . i(" AuthQuickstart" , " Confirm sign in not complete. There might be additional steps: " + result. getNextStep());
59
+ // Switch on the next step to take appropriate actions.
60
+ // If `signInResult.isSignedIn` is true, the next step
61
+ // is 'done', and the user is now signed in.
62
+ }
63
+ },
64
+ error - > Log . e(" AuthQuickstart" , " Confirm sign in failed: " + error)
65
+ );
66
+ ```
67
+ </Block >
68
+
69
+ <Block name = " Kotlin - Callbacks" >
70
+
71
+ ``` kotlin
72
+ Amplify .Auth .confirmSignIn(
73
+ " TOTP confirmation code" ,
74
+ { result ->
75
+ if (result.isSignedIn) {
76
+ Log .i(" AuthQuickstart" , " Confirm signIn succeeded" )
77
+ } else {
78
+ Log .i(
79
+ " AuthQuickstart" ,
80
+ " Confirm sign in not complete. There might be additional steps: ${result.nextStep} "
81
+ )
82
+ // Switch on the next step to take appropriate actions.
83
+ // If `signInResult.isSignedIn` is true, the next step
84
+ // is 'done', and the user is now signed in.
85
+ }
86
+ },
87
+ { error -> Log .e(" AuthQuickstart" , " Confirm sign in failed: $error " ) }
88
+ )
89
+ ```
90
+ </Block >
91
+
92
+ <Block name = " Kotlin - Coroutines" >
93
+
94
+ ``` kotlin
95
+ try {
96
+ val result = Amplify .Auth .confirmSignIn(
97
+ " confirmation code"
98
+ )
99
+ if (result.isSignedIn) {
100
+ Log .i(" AuthQuickstart" , " Confirm signIn succeeded" )
101
+ } else {
102
+ Log .i(" AuthQuickstart" , " Confirm sign in not complete. There might be additional steps: ${result.nextStep} " )
103
+ // Switch on the next step to take appropriate actions.
104
+ // If `signInResult.isSignedIn` is true, the next step
105
+ // is 'done', and the user is now signed in.
106
+ }
107
+ } catch (error: Exception ) {
108
+ Log .e(" AuthQuickstart" , " Unexpected error: $error " )
109
+ }
110
+ ```
111
+ </Block >
112
+
113
+ <Block name = " RxJava" >
114
+
115
+ ``` java
116
+ RxAmplify . Auth . confirmSignIn(
117
+ " TOTP confirmation code" ). subscribe(
118
+ result - > {
119
+ if (result. isSignedIn()) {
120
+ Log . i(" AuthQuickstart" , " Confirm signIn succeeded" );
121
+ } else {
122
+ Log . i(" AuthQuickstart" , " Confirm sign in not complete. There might be additional steps: " + result. getNextStep());
123
+ // Switch on the next step to take appropriate actions.
124
+ // If `signInResult.isSignedIn` is true, the next step
125
+ // is 'done', and the user is now signed in.
126
+ }
127
+ },
128
+ error - > Log . e(" AuthQuickstart" , " Confirm sign in failed: " + error)
129
+ );
130
+ ```
131
+ </Block >
132
+ </BlockSwitcher >
133
+
134
+ </InlineFilter >
135
+
46
136
<InlineFilter filters = { [' flutter' ]} >
47
137
48
138
``` dart
@@ -79,6 +169,77 @@ import iosContinueSignInWithMFASelectionCode from 'src/fragments/lib/auth/ios/si
79
169
80
170
<Fragments fragments = { { swift: iosContinueSignInWithMFASelectionCode }} />
81
171
172
+ <InlineFilter filters = { [' android' ]} >
173
+
174
+ <BlockSwitcher >
175
+ <Block name = " Java" >
176
+
177
+ ``` java
178
+ Amplify . Auth . confirmSignIn(
179
+ MFATypeUtil . getChallengeResponse(MFAType . TOTP ),
180
+ result - > {
181
+ if (result. getNextStep(). getSignInStep() == AuthSignInStep . CONFIRM_SIGN_IN_WITH_TOTP_CODE ) {
182
+ Log . i(" AuthQuickStart" , " Received next step as confirm sign in with TOTP" );
183
+ }
184
+ // ...
185
+ },
186
+ error - > Log . e(" AuthQuickstart" , " Confirm sign in failed: " + error)
187
+ );
188
+ ```
189
+
190
+ </Block >
191
+ <Block name = " Kotlin - Callbacks" >
192
+
193
+ ``` kotlin
194
+ Amplify .Auth .confirmSignIn(
195
+ MFAType .TOTP .challengeResponse,
196
+ { result ->
197
+ if (result.nextStep.signInStep == AuthSignInStep .CONFIRM_SIGN_IN_WITH_TOTP_CODE ) {
198
+ Log .i(" AuthQuickStart" , " Received next step as confirm sign in with TOTP" );
199
+ }
200
+ // ...
201
+ },
202
+ { error -> Log .e(" AuthQuickstart" , " Confirm sign in failed: $error " ) }
203
+ )
204
+ ```
205
+
206
+ </Block >
207
+ <Block name = " Kotlin - Coroutines" >
208
+
209
+ ``` kotlin
210
+ try {
211
+ val result = Amplify .Auth .confirmSignIn(MFAType .TOTP .challengeResponse)
212
+ if (result.nextStep.signInStep == AuthSignInStep .CONFIRM_SIGN_IN_WITH_TOTP_CODE ) {
213
+ Log .i(" AuthQuickStart" , " Received next step as confirm sign in with TOTP" );
214
+ }
215
+ // ...
216
+ } catch (error: Exception ) {
217
+ Log .e(" AuthQuickstart" , " Confirm sign in failed: $error " )
218
+ }
219
+ ```
220
+
221
+ </Block >
222
+ <Block name = " RxJava" >
223
+
224
+ ``` java
225
+ RxAmplify . Auth . confirmSignIn(
226
+ MFATypeUtil . getChallengeResponse(MFAType . TOTP )
227
+ ). subscribe(
228
+ result - > {
229
+ if (result. getNextStep(). getSignInStep() == AuthSignInStep . CONFIRM_SIGN_IN_WITH_TOTP_CODE ) {
230
+ Log . i(" AuthQuickStart" , " Received next step as confirm sign in with TOTP" );
231
+ }
232
+ // ...
233
+ },
234
+ error - > Log . e(" AuthQuickstart" , " Confirm sign in failed: " + error)
235
+ );
236
+ ```
237
+
238
+ </Block >
239
+ </BlockSwitcher >
240
+
241
+ </InlineFilter >
242
+
82
243
<InlineFilter filters = { [' flutter' ]} >
83
244
84
245
The MFA types which are currently supported by Amplify Auth are:
@@ -126,6 +287,149 @@ import iosContinueSignInWithMFASetup from 'src/fragments/lib/auth/ios/signin_nex
126
287
127
288
<Fragments fragments = { { swift: iosContinueSignInWithMFASetup }} />
128
289
290
+ <InlineFilter filters = { [' android' ]} >
291
+
292
+ <BlockSwitcher >
293
+ <Block name = " Java" >
294
+
295
+ ``` java
296
+
297
+ void handleSignInResult(AuthSignInResult result) {
298
+ switch (result. getNextStep(). getSignInStep()) {
299
+ // ...
300
+ case CONTINUE_SIGN_IN_WITH_TOTP_SETUP :
301
+ final TOTPSetupDetails totpSetupDetails = result. getNextStep(). getTotpSetupDetails();
302
+ final Uri setupUri = totpSetupDetails. getSetupURI(" MyAppName" );
303
+ Log . i(" AuthQuickStart" , " Open URI to complete setup: " + setupUri);
304
+ break ;
305
+ }
306
+ }
307
+
308
+ // Then, pass the TOTP code to `confirmSignIn`
309
+
310
+ Amplify . Auth . confirmSignIn(
311
+ totpCodeFromAuthenticatorApp,
312
+ result - > {
313
+ if (result. isSignedIn()) {
314
+ Log . i(" AuthQuickstart" , " Confirm signIn succeeded" );
315
+ } else {
316
+ Log . i(" AuthQuickstart" , " Confirm sign in not complete. There might be additional steps: " + result. getNextStep());
317
+ // Switch on the next step to take appropriate actions.
318
+ // If `signInResult.isSignedIn` is true, the next step
319
+ // is 'done', and the user is now signed in.
320
+ }
321
+ },
322
+ error - > Log . e(" AuthQuickstart" , " Confirm sign in failed: " + error)
323
+ );
324
+ ```
325
+
326
+ </Block >
327
+ <Block name = " Kotlin - Callbacks" >
328
+
329
+ ``` kotlin
330
+
331
+ fun handleSignInResult (result : AuthSignInResult ) {
332
+ when (result.nextStep.signInStep) {
333
+ // ...
334
+ AuthSignInStep .CONTINUE_SIGN_IN_WITH_TOTP_SETUP -> {
335
+ val totpSetupDetails = result.nextStep.totpSetupDetails
336
+ val setupUri = totpSetupDetails!! .getSetupURI(" MyAppName" )
337
+ Log .i(" AuthQuickStart" , " Open URI to complete setup: $setupUri " )
338
+ }
339
+ }
340
+ }
341
+
342
+ // Then, pass the TOTP code to `confirmSignIn`
343
+
344
+ Amplify .Auth .confirmSignIn(
345
+ totpCodeFromAuthenticatorApp,
346
+ { result ->
347
+ if (result.isSignedIn) {
348
+ Log .i(" AuthQuickstart" , " Confirm signIn succeeded" )
349
+ } else {
350
+ Log .i(" AuthQuickstart" , " Confirm sign in not complete. There might be additional steps: ${result.nextStep} " )
351
+ // Switch on the next step to take appropriate actions.
352
+ // If `signInResult.isSignedIn` is true, the next step
353
+ // is 'done', and the user is now signed in.
354
+ }
355
+ },
356
+ { error -> Log .e(" AuthQuickstart" , " Confirm sign in failed: $error " ) }
357
+ )
358
+ ```
359
+
360
+ </Block >
361
+ <Block name = " Kotlin - Coroutines" >
362
+
363
+ ``` kotlin
364
+
365
+ fun handleSignInResult (result : AuthSignInResult ) {
366
+ when (result.nextStep.signInStep) {
367
+ // ...
368
+ AuthSignInStep .CONTINUE_SIGN_IN_WITH_TOTP_SETUP -> {
369
+ val totpSetupDetails = result.nextStep.totpSetupDetails
370
+ val setupUri = totpSetupDetails!! .getSetupURI(" MyAppName" )
371
+ Log .i(" AuthQuickStart" , " Open URI to complete setup: $setupUri " )
372
+ }
373
+ }
374
+ }
375
+
376
+ // Then, pass the TOTP code to `confirmSignIn`
377
+
378
+ try {
379
+ val result = Amplify .Auth .confirmSignIn(totpCodeFromAuthenticatorApp)
380
+ if (result.isSignedIn) {
381
+ Log .i(" AuthQuickstart" , " Confirm signIn succeeded" )
382
+ } else {
383
+ Log .i(" AuthQuickstart" , " Confirm sign in not complete. There might be additional steps: ${result.nextStep} " )
384
+ // Switch on the next step to take appropriate actions.
385
+ // If `signInResult.isSignedIn` is true, the next step
386
+ // is 'done', and the user is now signed in.
387
+ }
388
+ } catch (error: Exception ) {
389
+ Log .e(" AuthQuickstart" , " Confirm sign in failed: $error " )
390
+ }
391
+ ```
392
+
393
+ </Block >
394
+ <Block name = " RxJava" >
395
+
396
+ ``` java
397
+ void handleSignInResult(AuthSignInResult result) {
398
+ switch (result. getNextStep(). getSignInStep()) {
399
+ // ...
400
+ case CONTINUE_SIGN_IN_WITH_TOTP_SETUP :
401
+ final TOTPSetupDetails totpSetupDetails = result. getNextStep(). getTotpSetupDetails();
402
+ final Uri setupUri = totpSetupDetails. getSetupURI(" MyAppName" );
403
+ Log . i(" AuthQuickStart" , " Open URI to complete setup: " + setupUri);
404
+ break ;
405
+ }
406
+ }
407
+
408
+
409
+ // Then, pass the TOTP code to `confirmSignIn`
410
+
411
+ RxAmplify . Auth . confirmSignIn(
412
+ totpCodeFromAuthenticatorApp
413
+ ). subscribe(
414
+ result - > {
415
+ if (result. isSignedIn()) {
416
+ Log . i(" AuthQuickstart" , " Confirm signIn succeeded" );
417
+ } else {
418
+ Log . i(" AuthQuickstart" , " Confirm sign in not complete. There might be additional steps: " + result. getNextStep());
419
+ // Switch on the next step to take appropriate actions.
420
+ // If `signInResult.isSignedIn` is true, the next step
421
+ // is 'done', and the user is now signed in.
422
+ }
423
+ },
424
+ error - > Log . e(" AuthQuickstart" , " Confirm sign in failed: " + error)
425
+ );
426
+ ```
427
+
428
+ </Block >
429
+ </BlockSwitcher >
430
+
431
+ </InlineFilter >
432
+
129
433
<InlineFilter filters = { [' flutter' ]} >
130
434
131
435
``` dart
0 commit comments