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

Migrate users with a Lambda Trigger #1136

Closed
Nikooos opened this issue Aug 19, 2019 · 17 comments
Closed

Migrate users with a Lambda Trigger #1136

Nikooos opened this issue Aug 19, 2019 · 17 comments
Labels
cognito Issues with the AWS Android SDK for Cognito feature-request Request a new feature

Comments

@Nikooos
Copy link

Nikooos commented Aug 19, 2019

I'm trying to migrate users from our existing user management system into our user pool without a password reset.

For iOS I found this example which explains that adding a boolean to the awsconfiguration.json with the key MigrationEnabled and value YES should do the magic. This works.

For Android I found an example which totally doesn't match our Kotlin setup. For Android we're also using the awsconfiguration.json, but the MigrationEnabled boolean is not doing any magic in this case. Unfortunately with this documentation I can't figure out how to do this in our Android app.

Can anyone point me in the right direction for this?

Environment:

  • SDK Version: 2.14.2
@desokroshan desokroshan added cognito Issues with the AWS Android SDK for Cognito question General question labels Aug 19, 2019
@patrickkempff
Copy link

Having the same issue, not sure how to set MigrationEnabled on Android

@palpatim
Copy link
Member

@Nikooos @patrickkempff It sounds like you are using AWSMobileClient to manage your app's authentication. If so, AWSMobileClient does not yet support custom migrations using Lambda Triggers.

Can you clarify which SDKs you're using?

@palpatim palpatim added the pending-community-response Issue is pending response from the issue requestor label Aug 26, 2019
@patrickkempff
Copy link

@palpatim thank you for your reply.

I am indeed using AWSMobileClient, mostly because the docs recommend it. Is there an other way to do it without the need of implementing scenario's like transitioning from offline to online and refreshing credentials at the appropriate time so that errors do not occur when actions are taken and connectivity is not available?

@htrujill
Copy link

htrujill commented Sep 4, 2019

Will custom migrations using LambdaTriggers be supported soon in AWSModileClient?

@desokroshan desokroshan removed the pending-community-response Issue is pending response from the issue requestor label Sep 10, 2019
@desokroshan desokroshan added feature-request Request a new feature and removed question General question labels Sep 25, 2019
@patrickkempff
Copy link

Any updates on this?

@kneekey23
Copy link

Adding our PM @nikhil-dabhade to add insight here on timeline for this feature request.

@fernandoaguilar
Copy link

any updates on this? We have the same issue and need this to work.

@VinnyScorsatto
Copy link

Any Updates on this?

@patrickkempff
Copy link

Any updates? 😢

@MichaelHighsmith
Copy link

Has anyone found a solution to this for Android? MigrationEnabled is working for iOS but that's it.

@MichaelHighsmith
Copy link

For anyone down the road I found the solution for Android. Rather than setting the migrationEnabled field, you need to create AuthenticationDetails and AuthenticationHandler objects, set the detail's authenticationType to "USER_PASSWORD", and then call initiateUserAuthentication on your cognitoUserPool instance. Below is an example:

val authenticationHandler: AuthenticationHandler = object : AuthenticationHandler {

override fun onSuccess(cognitoUserSession: CognitoUserSession?, device: CogntioDevice?) {
    //get your login token here
}

//other overridden methods here

}

val authDetails = AuthenticationDetails(email, password, null)
authDetails.authenticationType = "USER_PASSWORD"
cognitoUserPool?.currentUser?.initiateUserAuthentication(authDetails, authenticationHandler, true)?.run()

@fernandoaguilar
Copy link

to add to @MichaelHighsmith solution, we ended up doing the same thing and in the onSuccess call we just called login with amplify again and that handled the tokens for us.

@MichaelHighsmith
Copy link

@fernandoaguilar It seems that on a fresh install when I try to call cognitoUserPool?.currentUser, that user has a null userID which is throwing a wrench in the authentication. I think signing in a dummy user and then using that user's ID to do the real login would work, but it's definitely not the right way to go. Do you have any advice on how you got around this issue?

@fernandoaguilar
Copy link

@MichaelHighsmith create a cognito user with the users email when they login.

    CognitoUser cognitoUser = cognitoUserPool.getUser(email);

@MichaelHighsmith
Copy link

Wow I guess I'd been staring at this for too long...thanks for the help @fernandoaguilar !

@fernandoaguilar
Copy link

@MichaelHighsmith no problem!

@TrekSoft
Copy link
Contributor

TrekSoft commented Sep 1, 2020

Thanks for posting that solution @MichaelHighsmith and sorry everyone for the extended blackout on this ticket! Came up on my radar here with the large number of recent comments. I'll close the issue for now but if others are having difficulties with this, leave a comment and I can reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cognito Issues with the AWS Android SDK for Cognito feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests