@@ -1711,35 +1711,6 @@ if (confirmSignInNextStep.signInStep === 'DONE') {
17111711 console .log (' Sign in successful!' );
17121712}
17131713```
1714-
1715-
1716- ### First Factor Selection
1717-
1718- Omit the ` preferredChallenge ` parameter to discover what first factors are available for a given user.
1719-
1720- The ` confirmSignIn ` API can then be used to select a challenge and initiate the associated authentication flow.
1721-
1722- ``` ts
1723- const { nextStep : signInNextStep } = await signIn ({
1724- username: ' +15551234567' ,
1725- options: {
1726- authFlowType: ' USER_AUTH' ,
1727- },
1728- });
1729-
1730- if (
1731- signInNextStep .signInStep === ' CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION'
1732- ) {
1733- // present user with list of available challenges
1734- console .log (` Available Challenges: ${signInNextStep .availableChallenges } ` );
1735-
1736- // respond with user selection using `confirmSignIn` API
1737- const { nextStep : nextConfirmSignInStep } = await confirmSignIn ({
1738- challengeResponse: ' SMS_OTP' , // or 'EMAIL_OTP', 'WEB_AUTHN', 'PASSWORD', 'PASSWORD_SRP'
1739- });
1740- }
1741-
1742- ```
17431714</InlineFilter >
17441715
17451716<InlineFilter filters = { [" android" ]} >
@@ -1844,4 +1815,149 @@ RxAmplify.Auth.confirmSignIn("password")
18441815
18451816</InlineFilter >
18461817
1818+ <InlineFilter filters = { [" angular" , " javascript" , " nextjs" , " react" , " react-native" , " vue" , " android" ]} >
1819+ ### First Factor Selection
1820+
1821+ Omit the ` preferredChallenge ` parameter to discover what first factors are available for a given user.
1822+
1823+ The ` confirmSignIn ` API can then be used to select a challenge and initiate the associated authentication flow.
1824+ </InlineFilter >
1825+
1826+ <InlineFilter filters = { [" angular" , " javascript" , " nextjs" , " react" , " react-native" , " vue" ]} >
1827+ ``` ts
1828+ const { nextStep : signInNextStep } = await signIn ({
1829+ username: ' +15551234567' ,
1830+ options: {
1831+ authFlowType: ' USER_AUTH' ,
1832+ },
1833+ });
1834+
1835+ if (
1836+ signInNextStep .signInStep === ' CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION'
1837+ ) {
1838+ // present user with list of available challenges
1839+ console .log (` Available Challenges: ${signInNextStep .availableChallenges } ` );
1840+
1841+ // respond with user selection using `confirmSignIn` API
1842+ const { nextStep : nextConfirmSignInStep } = await confirmSignIn ({
1843+ challengeResponse: ' SMS_OTP' , // or 'EMAIL_OTP', 'WEB_AUTHN', 'PASSWORD', 'PASSWORD_SRP'
1844+ });
1845+ }
1846+
1847+ ```
1848+ </InlineFilter >
1849+
1850+ <InlineFilter filters = { [" android" ]} >
1851+ <BlockSwitcher >
1852+ <Block name = " Java" >
1853+
1854+ ``` java
1855+ // Retrieve the authentication factors by calling .availableFactors
1856+ AWSCognitoAuthSignInOptions options =
1857+ AWSCognitoAuthSignInOptions
1858+ .builder()
1859+ .authFlowType(AuthFlowType . USER_AUTH )
1860+ .callingActivity(callingActivity)
1861+ .build();
1862+ Amplify . Auth . signIn(
1863+ " username" ,
1864+ null ,
1865+ options,
1866+ result - > {
1867+ if (result. getNextStep(). getSignInStep() == AuthSignInStep . CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION ) {
1868+ Log . i(
1869+ " AuthQuickstart" ,
1870+ " Available authentication factors for this user: " + result. getNextStep(). getAvailableFactors()
1871+ );
1872+ }
1873+ },
1874+ error - > Log . e(" AuthQuickstart" , error. toString())
1875+ );
1876+ ```
1877+
1878+ </Block >
1879+ <Block name = " Kotlin - Callbacks" >
1880+
1881+ ``` kotlin
1882+ // Retrieve the authentication factors by calling .availableFactors
1883+ val options = AWSCognitoAuthSignInOptions .builder()
1884+ .authFlowType(AuthFlowType .USER_AUTH )
1885+ .callingActivity(callingActivity)
1886+ .build()
1887+ Amplify .Auth .signIn(
1888+ " username" ,
1889+ null ,
1890+ options,
1891+ { result ->
1892+ if (result.nextStep.signInStep == AuthSignInStep .CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION ) {
1893+ Log .i(
1894+ " AuthQuickstart" ,
1895+ " Available factors for this user: ${result.nextStep.availableFactors} "
1896+ )
1897+ }
1898+ },
1899+ { error ->
1900+ Log .e(" AuthQuickstart" , " Failed to sign in" , error)
1901+ }
1902+ )
1903+ ```
1904+
1905+ </Block >
1906+ <Block name = " Kotlin - Coroutines" >
1907+
1908+ ``` kotlin
1909+ try {
1910+ // Retrieve the authentication factors by calling .availableFactors
1911+ val options = AWSCognitoAuthSignInOptions .builder()
1912+ .authFlowType(AuthFlowType .USER_AUTH )
1913+ .callingActivity(callingActivity)
1914+ .build()
1915+ val result = Amplify .Auth .signIn(
1916+ username = " username" ,
1917+ password = null ,
1918+ options = options
1919+ )
1920+ if (result.nextStep.signInStep == AuthSignInStep .CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION ) {
1921+ Log .i(
1922+ " AuthQuickstart" ,
1923+ " Available factors for this user: ${result.nextStep.availableFactors} "
1924+ )
1925+ }
1926+ } catch (error: AuthException ) {
1927+ Log .e(" AuthQuickstart" , " Sign in failed" , error)
1928+ }
1929+ ```
1930+
1931+ </Block >
1932+ <Block name = " RxJava" >
1933+
1934+ ``` java
1935+ // Retrieve the authentication factors by calling .availableFactors
1936+ AWSCognitoAuthSignInOptions options =
1937+ AWSCognitoAuthSignInOptions
1938+ .builder()
1939+ .authFlowType(AuthFlowType . USER_AUTH )
1940+ .callingActivity(callingActivity)
1941+ .build();
1942+ RxAmplify . Auth . signIn(" username" , null , options)
1943+ .subscribe(
1944+ result - > {
1945+ if (result. getNextStep(). getSignInStep() == AuthSignInStep . CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION ) {
1946+ Log . i(
1947+ " AuthQuickstart" ,
1948+ " Available authentication factors for this user: " + result. getNextStep(). getAvailableFactors()
1949+ );
1950+ }
1951+ },
1952+ error - > Log . e(" AuthQuickstart" , error. toString())
1953+ );
1954+ ```
1955+
1956+ </Block >
1957+ </BlockSwitcher >
1958+
1959+ </InlineFilter >
1960+
1961+
1962+
18471963</InlineFilter >
0 commit comments