does the sst.Auth class support adding social logi...
# help
e
does the sst.Auth class support adding social login via the userpool?
f
Hi @Ernie Francis, you can get the user pool from
sst.Auth
and configure social login using CDK:
Copy code
const auth = new sst.Auth(this, "Auth", {...});

const provider = new cognito.UserPoolIdentityProviderAmazon(this, 'Amazon', {
  clientId: 'amzn-client-id',
  clientSecret: 'amzn-client-secret',
  userPool: auth.userpool,
});
e
ok, so how do i attach the userpool with the ideneity provider to the auth class?
Copy code
// create Auth
    const auth = new sst.Auth(this, 'Auth', {
      cognito: {
        userPool: {
          signInAliases: { email: true },
        },
      },
      google: {
        clientId: 'redacted',
      },
    });

    const testy = new cdk.aws_cognito.UserPoolIdentityProviderGoogle(this, 'testy', {
      userPool: auth.cognitoUserPool,
    });
f
Oh you don’t need to set
google
in
sst.Auth
. So there are two way to do social logins using Cognito.
^ I know it’s confusing.. there are many ways to do similar things in AWS 😔
Try this:
Copy code
const auth = new sst.Auth(this, 'Auth', {
      cognito: {
        userPool: {
          signInAliases: { email: true },
        },
      },
    });

    const testy = new cdk.aws_cognito.UserPoolIdentityProviderGoogle(this, 'testy', {
      clientId: "...",
      clientSecret: "...",
      userPool: auth.cognitoUserPool,
      attributeMapping: {
        ...
      }
    });
e
ok, ill try that out.
another question, when i run sst remove the userpool doesnt delete. is that intentional?
NVM, found it in CDK
f
e
welp, that didnt work
Copy code
TypeError: Cannot read properties of undefined (reading 'UserPoolIdentityProviderGoogle')
    at new BipStack (C:\Users\Asus\Documents\GitHub\bip\aws-backend\stacks\BipStack.ts:30:34)
    at Object.main (C:\Users\Asus\Documents\GitHub\bip\aws-backend\stacks\index.ts:16:3)
    at Object.<anonymous> (C:\Users\Asus\Documents\GitHub\bip\aws-backend\.build\run.js:94:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47
ill have to read more on aws-cdk. i went straight into serverless-stack with zero AWS code exp
i found the issue. i wa susing cdk v2 instead of v1
Copy code
Update the following AWS CDK packages to v2:

  - @aws-cdk/aws-cognito
  - @aws-cdk/core

More details on upgrading to CDK v2: <https://github.com/serverless-stack/serverless-stack/releases/tag/v0.59.0>
f
Ah I see. Did you manage to update to v2?
e
i did, had to look more into AWS-CDK to fix my use case. thanks for your help