Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify Auth with InstantApp #2991

Open
dzhumaliev opened this issue Feb 21, 2025 · 9 comments
Open

Amplify Auth with InstantApp #2991

dzhumaliev opened this issue Feb 21, 2025 · 9 comments
Labels
bug Something isn't working

Comments

@dzhumaliev
Copy link

Hey guys,
Thank you for supporting the libraries we use with pleasure—you’re doing a great job!
Recently, we updated the dependencies of the Amplify Auth project to version v2, and our Instant App crashed with a KeyStore error. As you know, Android Instant Apps don’t have access to the KeyStore, and this is preventing us from releasing our project.
Do you have any recommendations or solutions for this? I’d really appreciate it if you could reach out to me about it!

p.s. I understand that the KeyStore is used for securely storing keys and tokens, but perhaps there are some solutions or workarounds. I’d appreciate your response!

Isak Dzhumaliev
Feb 20, 2025

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Feb 21, 2025
@dzhumaliev
Copy link
Author

Error: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder android.system.keystore2.IKeystoreService.asBinder()' on a null object reference

@tylerjroach
Copy link
Member

Hi @dzhumaliev, Amplify v1 also used the KeyStore, however, if the KeyStore failed, it would fallback to an in memory key value repository. I believe this may be what would happen in your scenario, which would be beneficial for an instant app.

We actually just updated Amplify v2 in v2.26.0 to use an in memory fallback.

Can you tell me what version of Amplify v2 you attempted? Please update to the latest as I think it will work in your use case. If not, please provide us a more detailed crash log so that we can point to exactly where the crash is occurring.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
@tylerjroach tylerjroach added question General question pending-maintainer-response Issue is pending response from an Amplify team member labels Feb 21, 2025
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Feb 21, 2025
@dzhumaliev
Copy link
Author

dzhumaliev commented Feb 21, 2025

Got it, I updated version to v2.27.0 but it also crashed.
implementation "com.amplifyframework:aws-auth-cognito:2.27.0"

FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: digital.com.android, PID: 11753
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder android.system.keystore2.IKeystoreService.asBinder()' on a null object reference
at android.security.KeyStore2.getService(KeyStore2.java:144)
at android.security.KeyStore2.handleRemoteExceptionWithRetry(KeyStore2.java:105)
at android.security.KeyStore2.getKeyEntry(KeyStore2.java:252)
at android.security.keystore2.AndroidKeyStoreSpi.getKeyMetadata(AndroidKeyStoreSpi.java:156)
at android.security.keystore2.AndroidKeyStoreSpi.engineContainsAlias(AndroidKeyStoreSpi.java:1006)
at java.security.KeyStore.containsAlias(KeyStore.java:1314)
at com.amplifyframework.auth.cognito.data.LegacyKeyProvider.retrieveKey-IoAF18A(LegacyKeyProvider.kt:63)
at com.amplifyframework.auth.cognito.data.LegacyKeyValueRepository.retrieveEncryptionKey-IoAF18A(LegacyKeyValueRepository.kt:269)
at com.amplifyframework.auth.cognito.data.LegacyKeyValueRepository.get(LegacyKeyValueRepository.kt:161)
at com.amplifyframework.auth.cognito.data.AWSCognitoLegacyCredentialStore.getTokenKeys(AWSCognitoLegacyCredentialStore.kt:290)
at com.amplifyframework.auth.cognito.data.AWSCognitoLegacyCredentialStore.retrieveSignedInData(AWSCognitoLegacyCredentialStore.kt:209)
at com.amplifyframework.auth.cognito.data.AWSCognitoLegacyCredentialStore.retrieveCredential(AWSCognitoLegacyCredentialStore.kt:107)
at com.amplifyframework.auth.cognito.actions.CredentialStoreCognitoActions$migrateLegacyCredentialStoreAction$$inlined$invoke$1.execute(Action.kt:69)
at com.amplifyframework.statemachine.ConcurrentEffectExecutor$execute$1$1.invokeSuspend(ConcurrentEffectExecutor.kt:26)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:832)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@85af034, Dispatchers.Default]

@tylerjroach
Copy link
Member

Thank you! This is something we should be able to catch and allow the in memory fallback to take place.

@tylerjroach tylerjroach added bug Something isn't working and removed question General question labels Feb 21, 2025
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
@dzhumaliev
Copy link
Author

Thank you! Let's stay in touch!

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
@tylerjroach
Copy link
Member

I've got a PR up with a fix: #2993.

Once merged, the fix will go out in our next release. Thank you for the report!

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
@dzhumaliev
Copy link
Author

Thank you!
When can I expect the next release? Can you estimate the date pls?

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
@tylerjroach
Copy link
Member

We don't make specific release date commitments, but we do try to release once a week when we have updates to go out.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
@dzhumaliev
Copy link
Author

Perfect! Thanks!

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
@tylerjroach tylerjroach removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants