diff --git a/src/constants/versions.ts b/src/constants/versions.ts index 6d4685b7456..95c4fad6580 100644 --- a/src/constants/versions.ts +++ b/src/constants/versions.ts @@ -1,11 +1,11 @@ export const versions = { - ANDROID_VERSION: '2.24.0', + ANDROID_VERSION: '2.30.0', ANDROID_DEVPREVIEW: '1.36.5-dev-preview.0', ANDROID_V1_VERSION: '1.38.8', ANDROID_V1_GEO_VERSION: '1.0.1', ANDROID_V1_KOTLIN_VERSION: '0.22.8', - ANDROID_SDK_VERSION: '2.76.0', - KOTLIN_SDK_VERSION: '1.3.31', - ANDROID_AUTHENTICATOR_VERSION: '1.4.0', + ANDROID_SDK_VERSION: '2.81.0', + KOTLIN_SDK_VERSION: '1.5.15', + ANDROID_AUTHENTICATOR_VERSION: '1.6.0', ANDROID_APPSYNC_SDK_VERSION: '1.0.0' }; diff --git a/src/fragments/lib/auth/ios/signin_web_ui/40_private_session.mdx b/src/fragments/lib/auth/ios/signin_web_ui/40_private_session.mdx index f330edeba6f..e78bfa8e62c 100644 --- a/src/fragments/lib/auth/ios/signin_web_ui/40_private_session.mdx +++ b/src/fragments/lib/auth/ios/signin_web_ui/40_private_session.mdx @@ -10,4 +10,14 @@ try await Amplify.Auth.signInWithWebUI( ) { ... } + +// or + +try await Amplify.Auth.signInWithSocialWebUI( + for: .googleSignIn, + presentationAnchor: self.view.window!, + options: .preferPrivateSession() +) { + ... +} ``` diff --git a/src/fragments/lib/auth/native_common/signin_web_ui/common.mdx b/src/fragments/lib/auth/native_common/signin_web_ui/common.mdx index c6e57325b5b..3f4ca1ee7f0 100644 --- a/src/fragments/lib/auth/native_common/signin_web_ui/common.mdx +++ b/src/fragments/lib/auth/native_common/signin_web_ui/common.mdx @@ -65,3 +65,112 @@ import ios12 from '/src/fragments/lib/auth/ios/signin_web_ui/40_private_session. import flutter13 from '/src/fragments/lib/auth/flutter/signin_web_ui/40_private_session.mdx'; + + +### Prefer private session during signIn + +The `preferPrivateSession` option launches the authentication flow in an ephemeral browser state with no existing sessions or cookies. This ensures each authentication attempt begins from a clean, signed-out state, which is particularly useful for social sign-ins where third-party authentication cookies cannot be cleared. + + + + +```java +AWSCognitoAuthWebUISignInOptions options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build(); + +Amplify.Auth.signInWithWebUI( + this, + options, + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) +); + +// or + +Amplify.Auth.signInWithSocialWebUI( + AuthProvider.google(), + this, + options, + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) +); +``` + + + + +```kotlin +val options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build() + +Amplify.Auth.signInWithWebUI( + this, + options, + { Log.i("AuthQuickStart", "Signin OK = $it") }, + { Log.e("AuthQuickStart", "Signin failed", it) } +) + +// or + +Amplify.Auth.signInWithSocialWebUI( + AuthProvider.google(), + this, + options, + { Log.i("AuthQuickStart", "Signin OK = $it") }, + { Log.e("AuthQuickStart", "Signin failed", it) } +) +``` + + + + +```kotlin +val options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build() + +try { + val result = Amplify.Auth.signInWithWebUI(this, options) + Log.i("AuthQuickStart", "Signin OK: $result") +} catch (error: AuthException) { + Log.e("AuthQuickStart", "Signin failed", error) +} + +// or + +try { + val result = Amplify.Auth.signInWithSocialWebUI(AuthProvider.google(), this, options) + Log.i("AuthQuickStart", "Signin OK: $result") +} catch (error: AuthException) { + Log.e("AuthQuickStart", "Signin failed", error) +} +``` + + + + +```java +AWSCognitoAuthWebUISignInOptions options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build(); + +RxAmplify.Auth.signInWithWebUI(this, options) + .subscribe( + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) + ); + +// or + +RxAmplify.Auth.signInWithSocialWebUI(AuthProvider.google(), this, options) + .subscribe( + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) + ); +``` + + + + diff --git a/src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/index.mdx b/src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/index.mdx index 5f97f5e3e9c..65ea6d9886f 100644 --- a/src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/index.mdx +++ b/src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/index.mdx @@ -1052,6 +1052,82 @@ RxAmplify.Auth.signInWithSocialWebUI(AuthProvider.facebook(), this) +### Prefer private session during social Sign In + +The `preferPrivateSession` option launches the authentication flow in an ephemeral browser state with no existing sessions or cookies. This ensures each authentication attempt begins from a clean, signed-out state, which is particularly useful for social sign-ins where third-party authentication cookies cannot be cleared programmatically. + + + + +```java +AWSCognitoAuthWebUISignInOptions options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build(); + +// Replace facebook with your chosen auth provider such as google, amazon, or apple +Amplify.Auth.signInWithSocialWebUI( + AuthProvider.facebook(), + this, + options, + result -> Log.i("AuthQuickstart", result.toString()), + error -> Log.e("AuthQuickstart", error.toString()) +); +``` + + + + +```kotlin +val options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build() + +// Replace facebook with your chosen auth provider such as google, amazon, or apple +Amplify.Auth.signInWithSocialWebUI( + AuthProvider.facebook(), + this, + options, + { Log.i("AuthQuickstart", "Sign in OK: $it") }, + { Log.e("AuthQuickstart", "Sign in failed", it) } +) +``` + + + + +```kotlin +val options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build() + +try { + // Replace facebook with your chosen auth provider such as google, amazon, or apple + val result = Amplify.Auth.signInWithSocialWebUI(AuthProvider.facebook(), this, options) + Log.i("AuthQuickstart", "Sign in OK: $result") +} catch (error: AuthException) { + Log.e("AuthQuickstart", "Sign in failed", error) +} +``` + + + + +```java +AWSCognitoAuthWebUISignInOptions options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build(); + +// Replace facebook with your chosen auth provider such as google, amazon, or apple +RxAmplify.Auth.signInWithSocialWebUI(AuthProvider.facebook(), this, options) + .subscribe( + result -> Log.i("AuthQuickstart", result.toString()), + error -> Log.e("AuthQuickstart", error.toString()) + ); +``` + + + + @@ -1133,6 +1209,59 @@ func socialSignInWithWebUI() -> AnyCancellable { +### Prefer private session during social Sign In + +The `preferPrivateSession` option launches the authentication flow in an ephemeral browser state with no existing sessions or cookies. This ensures each authentication attempt begins from a clean, signed-out state, which is particularly useful for social sign-ins where third-party authentication cookies cannot be cleared programmatically. + + + + +```swift +func socialSignInWithWebUI() async { + do { + let signInResult = try await Amplify.Auth.signInWithWebUI( + for: .facebook, + presentationAnchor: self.view.window!, + options: .preferPrivateSession() + ) + if signInResult.isSignedIn { + print("Sign in succeeded") + } + } catch let error as AuthError { + print("Sign in failed \(error)") + } catch { + print("Unexpected error: \(error)") + } +} +``` + + + + +```swift +func socialSignInWithWebUI() -> AnyCancellable { + Amplify.Publisher.create { + try await Amplify.Auth.signInWithWebUI( + for: .facebook, + presentationAnchor: self.view.window!, + options: .preferPrivateSession() + ) + }.sink { + if case let .failure(authError) = $0 { + print("Sign in failed \(authError)") + } + } + receiveValue: { signInResult in + if signInResult.isSignedIn { + print("Sign in succeeded") + } + } +} +``` + + + + diff --git a/src/pages/[platform]/build-a-backend/auth/sign-in-with-web-ui/index.mdx b/src/pages/[platform]/build-a-backend/auth/sign-in-with-web-ui/index.mdx index cda3ce8918a..e00d92d95d9 100644 --- a/src/pages/[platform]/build-a-backend/auth/sign-in-with-web-ui/index.mdx +++ b/src/pages/[platform]/build-a-backend/auth/sign-in-with-web-ui/index.mdx @@ -123,6 +123,113 @@ RxAmplify.Auth.signInWithWebUI(this) +### Prefer private session during signIn + +The `preferPrivateSession` option launches the authentication flow in an ephemeral browser state with no existing sessions or cookies. This ensures each authentication attempt begins from a clean, signed-out state, which is particularly useful for social sign-ins where third-party authentication cookies cannot be cleared programmatically. + + + + +```java +AWSCognitoAuthWebUISignInOptions options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build(); + +Amplify.Auth.signInWithWebUI( + this, + options, + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) +); + +// or + +Amplify.Auth.signInWithSocialWebUI( + AuthProvider.google(), + this, + options, + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) +); +``` + + + + +```kotlin +val options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build() + +Amplify.Auth.signInWithWebUI( + this, + options, + { Log.i("AuthQuickStart", "Signin OK = $it") }, + { Log.e("AuthQuickStart", "Signin failed", it) } +) + +// or + +Amplify.Auth.signInWithSocialWebUI( + AuthProvider.google(), + this, + options, + { Log.i("AuthQuickStart", "Signin OK = $it") }, + { Log.e("AuthQuickStart", "Signin failed", it) } +) +``` + + + + +```kotlin +val options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build() + +try { + val result = Amplify.Auth.signInWithWebUI(this, options) + Log.i("AuthQuickStart", "Signin OK: $result") +} catch (error: AuthException) { + Log.e("AuthQuickStart", "Signin failed", error) +} + +// or + +try { + val result = Amplify.Auth.signInWithSocialWebUI(AuthProvider.google(), this, options) + Log.i("AuthQuickStart", "Signin OK: $result") +} catch (error: AuthException) { + Log.e("AuthQuickStart", "Signin failed", error) +} +``` + + + + +```java +AWSCognitoAuthWebUISignInOptions options = AWSCognitoAuthWebUISignInOptions.builder() + .preferPrivateSession(true) + .build(); + +RxAmplify.Auth.signInWithWebUI(this, options) + .subscribe( + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) + ); + +// or + +RxAmplify.Auth.signInWithSocialWebUI(AuthProvider.google(), this, options) + .subscribe( + result -> Log.i("AuthQuickStart", result.toString()), + error -> Log.e("AuthQuickStart", error.toString()) + ); +``` + + + + @@ -260,6 +367,16 @@ try await Amplify.Auth.signInWithWebUI( ) { ... } + +// or + +try await Amplify.Auth.signInWithWebUI( + for: .googleSignIn, + presentationAnchor: self.view.window!, + options: .preferPrivateSession() +) { + ... +} ```