简体   繁体   中英

Migrating users from cognito userpool to identity pool

AWS SDK (JavaScript)

I ported all of my users from a MSSQL DB to a AWS Cognito UserPool. Now I need to have each one of my Cognito users in my Identity pool. This needs to happen so I can move my user data into Cognito Sync's datasets.

Problem : I cannot move each cognito user in my userpool to my identity pool. I have searched the docs and I cannot seem to findout how to go about this.

I cannot log each user in because each user will need to reset their own password. (this is due to the way things are when porting users from a .csv file)

SOLVED

  • I loop through users in a batch.
  • Each user is converted to a Cognito User in a User Pool
  • Once the Cognito User is successfully added, I then log that user in manually,
  • Then I have to set the users password with a temp password
  • Next I get the successful method called
  • Inside the success method, I now have the user in the Identity pool because I logged the user in manually
  • Now I get the users Identity ID
  • Now I can set DataSets
  • NEXT IMPORTANT I have to set the user back to "RESET REQUIRED"
  • Then the loop continues and I process the next user in the batch

NOTE Make sure you do not have anything checked in you MFA portion in the Userpool or emails will be sent. Also emails are still sent in special circumstances. To get around this, I performed this task

  • Change the users email to fake@fake.com
  • All emails are sent to fake@fake.com
  • when you are done with the user and all is well, change the users email back to the correct email.

First, Identity Pool does not have users - just identities. Each identity corresponds to a User (A Userpool user or a Google/FB user) in case of authenticated identities and has an IdentityId (for all identities - authenticated & unauthenticated). This is generated when a GetId API call is made with an IdToken from the appropriate IdP (Userpool in your case).

Also, I don't see why you need to generate identities for all the users in your userpool. These identities are supposed to be generated on-the-fly. Design & deploy your app and when a user uses your app for the first time, your app will make a GetId call, thus generating an IdentityId.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM