aws-amplify / amplify-android

The fastest and easiest way to use AWS from your Android app.
https://docs.amplify.aws/lib/q/platform/android/
Apache License 2.0
246 stars 117 forks source link

Cannot replicate SAML Cognito login from Swift in Kotlin (parity) #2414

Closed drmarkpowell closed 1 year ago

drmarkpowell commented 1 year ago

Before opening, please confirm:

Language and Async Model

Kotlin - Coroutines

Amplify Categories

Authentication

Gradle script dependencies

```groovy // Put output below this line ```

Environment information

``` # Put output below this line ```

Please include any relevant guides or documentation you're referencing

https://docs.amplify.aws/lib/auth/signin_web_ui/q/platform/android/

Describe the bug

I have successfully written a SwiftUI app using amplify-swift that authenticates using Cognito with my employer's SAML provider. I am trying to write the equivalent Kotlin/Jetpack Compose app and I haven't been able to understand how to write an equivalent Amplify.Auth.signinWithWebUI style function call to invoke a signin using the custom auth provider.

I have provided the working SwiftUI example and my current Kotlin code that I'm trying to write. The first runBlocking in MainActivity.onCreate that tests whether the session is currently signed in does appear to work, as evidenced in the log output (isSignedIn: false, error: null, type: SUCCESS)

The second runBlocking in MainActivity.onCreate that calls .signinWithWebUI just freezes up execution and logs nothing at all.

There doesn't appear to be any equivalent AuthProvider of type SAML in the Kotlin codebase from what I can see...just a AuthProvider.custom that is likely there for us to work down the "escape hatch", as it is referred to in the docs?

Please help either educate me by pointing out where the feature parity is here that I haven't been able to find or take this as a request to provide parity for this authentication flow. Thank you!

Reproduction steps (if applicable)

No response

Code Snippet

SwiftUI example

@main

struct AmplifyApp: App {
    init() {
        do {
            Amplify.Logging.logLevel = .verbose
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.add(plugin: AWSS3StoragePlugin())
            try Amplify.configure()
            print("Amplify configured with auth plugin")
        } catch {
            print("Failed to initialize Amplify with \(error)")
        }
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }

    static var window: UIWindow? {
        guard let scene = UIApplication.shared.connectedScenes.first,
              let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate,
              let window = windowSceneDelegate.window else {
            return nil
        }
        return window
    }
}

struct ContentView: View {
    @State private var rawDataString = "Data is not yet loaded."

    var body: some View {
        VStack {
            Text(rawDataString)
        }
        .padding()
        .task { @MainActor in
            let identityPool = "myIdentityPoolName"
            let signedIn = await amplify.isSignedIn()
            if !signedIn {
                let window = AmplifyApp.window
                await signIn(identityPoolConfigName: identityPool, window: window)
            } else {
                os_log(.info, "user signed in")
            }
            if let text = await downloadFile(key: "myimage.jpg") {
                rawDataString = "\(text.count) bytes of data loaded."
            }
        }
    }
    
    func isSignedIn() async -> Bool {
        do {
            let session = try await Amplify.Auth.fetchAuthSession()
            return session.isSignedIn
        } catch let error as AuthError {
            os_log(.error, "Authentication error: \(error.localizedDescription)")
        } catch let error {
            os_log(.error, "Unexpected error: \(error.localizedDescription)")
        }
        return false
    }

    func signIn(identityPoolConfigName: String, window: UIWindow?) async {
        do {
            let session = try await Amplify.Auth.signInWithWebUI(
                for: .saml(identityPoolConfigName),
                presentationAnchor: window,
                options: preferPrivateSession()
            )
            print("user signed in - \(session.isSignedIn)")
        } catch let error as AuthError {
            print("Fetch session failed with error \(error.localizedDescription)")
        } catch {
            print("Unexpected error: \(error.localizedDescription)")
        }
    }
}

build.gradle

plugins {  
    id 'com.android.application'  
    id 'org.jetbrains.kotlin.android'  
}  

android {  
    namespace 'com.itsme.androidamplify'  
    compileSdk 33  

    defaultConfig {  
        applicationId "com.itsme.androidamplify"  
        minSdk 24  
        targetSdk 33  
        versionCode 10000  
        versionName "1.0.0"  

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  
        vectorDrawables {  
            useSupportLibrary true  
        }  
    }  
    buildTypes {  
        release {  
            minifyEnabled false  
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'  
        }  
    }    
    compileOptions {  
        coreLibraryDesugaringEnabled true  
        sourceCompatibility JavaVersion.VERSION_1_8  
        targetCompatibility JavaVersion.VERSION_1_8  
    }  
    kotlinOptions {  
        jvmTarget = '1.8'  
    }  
    buildFeatures {  
        compose true  
    }  
    composeOptions {  
        kotlinCompilerExtensionVersion '1.3.2'  
    }  
    packagingOptions {  
        resources {  
            excludes += '/META-INF/{AL2.0,LGPL2.1}'  
        }  
    }}  

dependencies {  

    implementation 'androidx.core:core-ktx:1.8.0'  
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'  
    implementation 'androidx.activity:activity-compose:1.5.1'  
    implementation platform('androidx.compose:compose-bom:2022.10.00')  
    implementation 'androidx.compose.ui:ui'  
    implementation 'androidx.compose.ui:ui-graphics'  
    implementation 'androidx.compose.ui:ui-tooling-preview'  
    implementation 'androidx.compose.material3:material3'  
    testImplementation 'junit:junit:4.13.2'  
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'  
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'  
    androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')  
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4'  
    debugImplementation 'androidx.compose.ui:ui-tooling'  
    debugImplementation 'androidx.compose.ui:ui-test-manifest'  

    // Amplify API and Datastore dependencies  
    implementation 'com.amplifyframework:aws-api:2.6.0'  
    implementation 'com.amplifyframework:aws-auth-cognito:2.6.0'  
    implementation 'com.amplifyframework:aws-datastore:2.6.0'  
    implementation 'com.amplifyframework:aws-storage-s3:2.6.0'  
    implementation 'com.amplifyframework:core-kotlin:2.6.0'  

    // Support for Java 8 features  
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'  

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:tools="http://schemas.android.com/tools">  

    <application
        android:allowBackup="true"  
        android:dataExtractionRules="@xml/data_extraction_rules"  
        android:fullBackupContent="@xml/backup_rules"  
        android:icon="@mipmap/ic_launcher"  
        android:label="@string/app_name"  
        android:name=".AmplifyApp"  
        android:roundIcon="@mipmap/ic_launcher_round"  
        android:supportsRtl="true"  
        android:theme="@style/Theme.AndroidAmplify"  
        tools:targetApi="31">  
        <activity      
            android:name=".MainActivity"  
            android:exported="true"  
            android:label="@string/app_name"  
            android:theme="@style/Theme.AndroidAmplify">  
            <intent-filter>        
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>        
        </activity>        
        <activity            
            android:name="com.amplifyframework.auth.cognito.activities.HostedUIRedirectActivity"  
            android:exported="true">  
            <intent-filter>                
                <action android:name="android.intent.action.VIEW" />  
                <category android:name="android.intent.category.DEFAULT" />  
                <category android:name="android.intent.category.BROWSABLE" />  
                <data android:scheme="myapp" />  
            </intent-filter>
        </activity>
    </application>  
</manifest>

MainActivity.kt

class MainActivity : ComponentActivity() {  
    override fun onCreate(savedInstanceState: Bundle?) {  
        super.onCreate(savedInstanceState)  

        try {  
            Amplify.addPlugin(AWSCognitoAuthPlugin())  
            Amplify.addPlugin(AndroidLoggingPlugin(LogLevel.VERBOSE))  
            Amplify.configure(applicationContext)  
            Log.i("AmplifyConfiguration", "Initialized Amplify")  
        } catch (error: AmplifyException) {  
            Log.e("AmplifyConfiguration", "Could not initialize Amplify", error)  
        }  

        var signedIn = false  
        runBlocking {  
            try {  
                val session = Amplify.Auth.fetchAuthSession()  
                Log.i("AmplifyAuth", "Auth session = $session")  
                signedIn = session.isSignedIn  
            } catch (error: AuthException) {  
                Log.e("AmplifyAuth", "Failed to fetch auth session", error)  
            }  
        }  
        runBlocking {  
            try {  
                if (!signedIn) {  
                    val result = Amplify.Auth.signInWithWebUI(this@MainActivity)  
                    Log.i("AmplifyAuth", "Sign in successful: $result")  
                } else {  
                    Log.i("AmplifyAuth", "Already signed in")  
                }  
            } catch (error: AuthException) {  
                Log.e("AmplifyAuth", "Failed to sign in")  
            }  
        }  

        setContent {  
            AndroidAmplifyTheme {  
                // A surface container using the 'background' color from the theme  
                Surface(  
                    modifier = Modifier.fillMaxSize(),  
                    color = MaterialTheme.colorScheme.background  
                ) {  
                    Greeting("Android")  
                }  
            } 
       }
   }  
}

Log output

``` // Put your logs below this line 2023-04-25 17:13:46.777 15879-15879 ActivityThread com.itsme.androidamplify W Application com.itsme.androidamplify is waiting for the debugger on port 8100... 2023-04-25 17:13:46.782 15879-15879 System.out com.itsme.androidamplify I Sending WAIT chunk 2023-04-25 17:13:47.788 15879-15879 System.out com.itsme.androidamplify I Debugger has connected 2023-04-25 17:13:47.788 15879-15879 System.out com.itsme.androidamplify I waiting for debugger to settle... 2023-04-25 17:13:48.798 15879-15879 chatty com.itsme.androidamplify I uid=10147(com.itsme.androidamplify) identical 5 lines 2023-04-25 17:13:48.999 15879-15879 System.out com.itsme.androidamplify I waiting for debugger to settle... 2023-04-25 17:13:49.201 15879-15879 System.out com.itsme.androidamplify I debugger has settled (1399) 2023-04-25 17:13:50.092 15879-15879 WM-WrkMgrInitializer com.itsme.androidamplify D Initializing WorkManager with default configuration. 2023-04-25 17:13:50.143 15879-15924 libEGL com.itsme.androidamplify D Emulator has host GPU support, qemu.gles is set to 1. 2023-04-25 17:13:50.138 15879-15879 RenderThread com.itsme.androidamplify W type=1400 audit(0.0:131): avc: denied { write } for name="property_service" dev="tmpfs" ino=7380 scontext=u:r:untrusted_app:s0:c147,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.itsme.androidamplify 2023-04-25 17:13:50.144 15879-15924 libc com.itsme.androidamplify W Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied) 2023-04-25 17:13:50.160 15879-15924 libEGL com.itsme.androidamplify D loaded /vendor/lib64/egl/libEGL_emulation.so 2023-04-25 17:13:50.161 15879-15924 libEGL com.itsme.androidamplify D loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so 2023-04-25 17:13:50.162 15879-15924 libEGL com.itsme.androidamplify D loaded /vendor/lib64/egl/libGLESv2_emulation.so 2023-04-25 17:13:50.403 15879-15879 NetworkSecurityConfig com.itsme.androidamplify D No Network Security Config specified, using platform default 2023-04-25 17:13:50.516 15879-15879 AmplifyConfiguration com.itsme.androidamplify I Initialized Amplify 2023-04-25 17:13:50.654 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) 2023-04-25 17:13:50.655 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) 2023-04-25 17:13:50.655 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) 2023-04-25 17:13:50.655 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed) 2023-04-25 17:13:50.655 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) 2023-04-25 17:13:50.656 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed) 2023-04-25 17:13:50.657 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) 2023-04-25 17:13:50.657 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) 2023-04-25 17:13:50.657 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) 2023-04-25 17:13:50.657 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed) 2023-04-25 17:13:50.658 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, linking, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->peekLong(JZ)J (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->pokeLong(JJZ)V (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->pokeInt(JIZ)V (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->peekInt(JZ)I (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->pokeByte(JB)V (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->peekByte(J)B (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->pokeByteArray(J[BII)V (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Llibcore/io/Memory;->peekByteArray(J[BII)V (greylist, reflection, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed) 2023-04-25 17:13:50.660 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->arrayIndexScale(Ljava/lang/Class;)I (greylist, linking, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, reflection, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, reflection, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, reflection, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, reflection, allowed) 2023-04-25 17:13:50.661 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, reflection, allowed) 2023-04-25 17:13:50.668 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) 2023-04-25 17:13:50.751 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) 2023-04-25 17:13:50.752 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) 2023-04-25 17:13:50.752 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) 2023-04-25 17:13:50.760 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) 2023-04-25 17:13:50.760 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) 2023-04-25 17:13:50.761 15879-15925 landroidamplif com.itsme.androidamplify W Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) 2023-04-25 17:13:50.778 15879-15925 EngineFactory com.itsme.androidamplify I Provider GmsCore_OpenSSL not available 2023-04-25 17:13:50.820 15879-15879 landroidamplif com.itsme.androidamplify W Long monitor contention with owner pool-2-thread-1 (15948) at void sun.misc.Unsafe.park(boolean, long)(Unsafe.java:-2) waiters=0 in boolean com.amplifyframework.core.category.Category.isConfigured() for 302ms 2023-04-25 17:13:50.880 15879-15925 System.err com.itsme.androidamplify W SLF4J: No SLF4J providers were found. 2023-04-25 17:13:50.880 15879-15925 System.err com.itsme.androidamplify W SLF4J: Defaulting to no-operation (NOP) logger implementation 2023-04-25 17:13:50.880 15879-15925 System.err com.itsme.androidamplify W SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. 2023-04-25 17:13:51.977 15879-15879 AmplifyAuth com.itsme.androidamplify I Auth session = AWSCognitoAuthSession(isSignedIn=false, identityIdResult=AuthSessionResult{value=us-west-1:abcdefa-1234-1234-1234-1234567890ab, error=null, type=SUCCESS}, awsCredentialsResult=AuthSessionResult{value=com.amplifyframework.auth.AWSTemporaryCredentials@10d91e9, error=null, type=SUCCESS}, userSubResult=AuthSessionResult{value=null, error=SignedOutException{message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}, userPoolTokensResult=AuthSessionResult{value=null, error=SignedOutException{message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}) ``` ```

amplifyconfiguration.json

{  
    "comment": "this config file is used by Amplify SDK",  
    "UserAgent": "aws-amplify-cli/2.0",  
    "Version": "1.0",  
    "auth": {  
        "plugins": {  
            "awsCognitoAuthPlugin": {  
                "IdentityManager": {  
                    "Default": {}  
                },  
                "CredentialsProvider": {  
                    "CognitoIdentity": {  
                        "Default": {  
                            "PoolId": "us-west-1:abcdefa-1234-1234-1234-1234567890ab",  
                            "Region": "us-west-1"  
                        }  
                    }  
                },  
                "CognitoUserPool": {  
                    "Default": {  
                        "PoolId": "us-west-1_1A2B3C4D5",  
                        "AppClientId": "abcdefghijklmnopqrstuvwxyz",  
                        "Region": "us-west-1"  
                    }  
                },  
                "Auth": {  
                    "Default": {  
                        "authenticationFlowType": "USER_SRP_AUTH",  
                        "OAuth": {  
                            "WebDomain": "myapp.us-west-1.amazoncognito.com",  
                            "AppClientId": "abcdefghijklmnopqrstuvwxyz",  
                            "SignInRedirectURI": "myapp://signin",  
                            "SignOutRedirectURI": "myapp://signout",  
                            "Scopes": [  
                                "phone",  
                                "email",  
                                "openid",  
                                "profile",  
                                "aws.cognito.signin.user.admin"  
                            ]  
                        }  
                    }  
                }  
            }  
        }  
    },  
    "storage": {  
        "plugins": {  
            "awsS3StoragePlugin": {  
                "bucket": "databucket",  
                "region": "us-west-1"  
            }  
        }  
    }  
}

GraphQL Schema

```graphql // Put your schema below this line ```

Additional information and screenshots

No response

tylerjroach commented 1 year ago

Hi @drmarkpowell

I believe what you are looking for is

Amplify.Auth.signInWithWebUI(
  this@MainActivity, 
  AWSCognitoAuthWebUISignInOptions.builder().idpIdentifier("<insert-idp-identifier>").build()
)

Please try this out and follow up if you are still experiencing issues.

drmarkpowell commented 1 year ago

Thank you for responding to this so quickly! I tried to follow your advice by adding the following:

val result = Amplify.Auth.signInWithWebUI(this@MainActivity,
                        AWSCognitoAuthWebUISignInOptions.builder()
                            .idpIdentifier("myIDPstring")
                            .scopes(scopes) // list of strings, same as those in amplifyconfiguration.json
                            .build()
                    )

However, the app still freezes on executing this line. I tried it both with and without including scopes explicitly in the builder, but got the same result.

What I would expect is for Chrome to be used to present a sign in page. What I am seeing is no transfer of control to Chrome at all and my app freezes.

Does this sign in execution path implicitly work with a SAML provider, or are additional configuration options needed to make that work correctly?

tylerjroach commented 1 year ago

@drmarkpowell

Your coroutine calls should not be in runBlocking calls. That is causing a lock on the main thread.

Instead, you will want to launch from a coroutine scope.

drmarkpowell commented 1 year ago

Yep, that was it exactly, you are right. I launched from a coroutine scope and it worked great, signed in and everything is cool.

I can't find where I found that example that used runBlocking { ... } but it was clearly not a good idea.

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.