Closed drmarkpowell closed 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.
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?
@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.
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.
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.
Before opening, please confirm:
Language and Async Model
Kotlin - Coroutines
Amplify Categories
Authentication
Gradle script dependencies
Environment information
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
inMainActivity.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
inMainActivity.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 aAuthProvider.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
build.gradle
AndroidManifest.xml
MainActivity.kt
Log output
amplifyconfiguration.json
GraphQL Schema
Additional information and screenshots
No response