问题
I'm following these pages to use cognito on my mobile app https://docs.aws.amazon.com/aws-mobile/latest/developerguide/getting-started.html and https://aws.amazon.com/blogs/mobile/easy-sign-in-and-sign-up-ui-with-the-aws-mobile-sdk-for-android/
I have created the mobile hub and downloaded the json file but now it wants me to create a cognito user pool, but I already have one. How can I link the mobile hub with the existing user pool?
Thanks.
回答1:
AWS Mobile Hub does not currently provide a means to import your existing Cognito User Pool into the project, however, you can use whatever Cognito User Pool you like with the Mobile Hub-generated Cognito Identity Pool with a few easy steps. First, add a User Pool to the Mobile Hub project, so the project has Auth enabled. Then click on the Resources link and find your Cognito Identity Pool, and click the deep-link to the Cognito console. Now, click to Edit your Identity Pool. Under "Authentication Providers" you'll find settings for the Cognito User Pool; set those values based on your Cognito User Pool. Then, go back into the Mobile Hub console and when you download the configuration file for whatever app platform you want, just edit the resulting file to put in the correct Cognito User Pool settings.
For example, if you're using Android, in the Mobile Hub console, you'll click "Integrate" on the Android card, and "Download Config File." Then, you'd edit these lines in the "awsconfiguration.json" file.
"CognitoUserPool": {
"Default": {
"PoolId": "us-east-1_9rEQUqXYZ",
"AppClientId": "gsdnilro5k0hillo8t6ojlxyz",
"AppClientSecret": "pkqbqn8ulo08lghald06sjeib4mvbvpd6b0qork2h30n5klixyz",
"Region": "us-east-1"
}
},
...to use the appropriate values for your Cognito User Pool, and you should be good to go.
Note that these instructions should let you re-use the Cognito User Pool, but because the Cognito Identity Pool has changed, your user identity ID values will change.
We have had several customers request being able to re-use their Cognito User Pool and Cognito Identity Pool, so we are working on prioritizing those requests, but I can't say exactly when that functionality would be available.
Sincerely,
Andrew C
AWS Mobile Developer Experience
回答2:
AWS now supports the feature you requested.
New AWS Mobile Hub feature: Add an existing user pool to your Mobile Hub project
来源:https://stackoverflow.com/questions/48511066/how-to-link-my-mobile-hub-with-my-existing-cognito-user-pool