5

To share the same aws cognito pool between two web clients do we just generate a new web client, allow amplify to setup the cognito pool, and replace the generated configuration parameters with the following parameters from the existing pool:

    "aws_project_region": "us-east-1",
    "aws_cognito_identity_pool_id": "us-east-1:8b81-8b47-aea37d",
    "aws_cognito_region": "us-east-1",
    "aws_user_pools_id": "us-east-1_ngkACLtve"

Thus we we only be left with a new aws_user_pools_web_client_id setting like this:

    "aws_user_pools_web_client_id": "7e0b47c4m",

And the oauth domain and redirect links will be different:

    "oauth": {
        "domain": "amp82-dev.auth.us-east-1.amazoncognito.com",
        "scope": [
            "phone",
            "email",
            "openid",
            "profile",
            "aws.cognito.signin.user.admin"
        ],
        "redirectSignIn": "http://localhost:4200/",
        "redirectSignOut": "http://localhost:4200/",
        "responseType": "code"
    },

But everything else is the same. I think this is right but wanted to double check whether I have left any steps out.

Ole
  • 41,793
  • 59
  • 191
  • 359
  • For your example are you modifying the aws-exports file directly? – pg316 Mar 27 '23 at 16:58
  • That's the idea. The parameters from the pool shared pool would just be introduced into the newly generated `aws-exports` file ... – Ole Mar 27 '23 at 17:45
  • Are you trying to use the same user pool in two separate projects or trying to use a different pool between mobile and desktop in the same project? Also what type of project is this? Angular, react, etc... – pg316 Mar 28 '23 at 14:23
  • Same user pool between two different Angular web clients. – Ole Mar 28 '23 at 17:02
  • If I am understanding correctly and you have 2 separate amplify projects then you should be able to configure each project to use the proper Amplify Web Client without needing to modify the aws-config file manually. In the end I think it will make your life easier to not have to modify that file manually as it is auto-generated and you would loose your changes. Please let me know if I am missing something here – pg316 Mar 28 '23 at 22:26
  • I actually have not looked at this in a while ... It's possible that the CLI walks through the pointing of the project configuration to an existing pool at this point ... – Ole Mar 29 '23 at 14:50
  • Are you using an already existing amazon user pool or was it created by Amplify? If you are using an already existing pool then you should be able to go to Amplify Studio and make the change for each project and then re-fetch the updates through amplify. If you had amplify create the pool through the cli I am not sure you can change the web clients then. – pg316 Mar 29 '23 at 18:25

0 Answers0