I have used AWS Amplify ("amplify add auth" in the terminal) to create a user pool in AWS Cognito with my React Native app but I don't know how to connect this same user pool to my React App. As far as I can see the Amplify Cli only gives options to create a new resource... Does anyone know how to connect it to an already existing/in use user pool?
Asked
Active
Viewed 993 times
2
-
Does this answer your question? [Integrate existing AWS Cognito user pool into iOS project with Amplify](https://stackoverflow.com/questions/53314155/integrate-existing-aws-cognito-user-pool-into-ios-project-with-amplify) – morgler Dec 07 '20 at 10:36
2 Answers
1
You can use the same pool with any frameworks. Make sure you pass in the right user pool configuration.
// AppSync client instantiation
const client = new AWSAppSyncClient({
url: AppSync.graphqlEndpoint,
region: AppSync.region,
auth: {
// IAM
// type: AUTH_TYPE.AWS_IAM,
// credentials: () => Auth.currentCredentials(),
// COGNITO USER POOLS
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
jwtToken: async () => (await Auth.currentSession()).getAcceessToken().getJwtToken(),
},
});

Kannaiyan
- 12,554
- 3
- 44
- 83
0
I had the same doubt today and after searching, it's possible to use the same user pool.
Check the user pools configuration in your AWS Console and replace as it follows:
import Amplify from 'aws-amplify';
...
Amplify.configure({
Auth: {
// REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab',
// REQUIRED - Amazon Cognito Region
region: 'XX-XXXX-X',
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'XX-XXXX-X_abcd1234',
// OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3'
}
});

thaís.w
- 11
- 4