Angular 使用UserPoolId&;具有角度应用程序的ClientId键

Angular 使用UserPoolId&;具有角度应用程序的ClientId键,angular,authentication,amazon-cognito,Angular,Authentication,Amazon Cognito,我被要求做一个编码挑战,并构建一个使用AWS Cognito进行身份验证的迷你应用程序 我已经给出了以下关键点: UserPoolId: "us-east-1_dJfLT4QIp" ClientId: "194t5jewd8o56ppmbjjlvdt6yi" (不是真正的细节) 我可以轻松地学习本教程: 从没有AWS帐户到使用AWS Cognito登录,我不知道如何将提供的密钥集成到我的应用程序中 是否可以在我的应用程序中的某个位置设置这些密钥以访问预先存在的用户池 这是目前我拥有的最有希望的

我被要求做一个编码挑战,并构建一个使用AWS Cognito进行身份验证的迷你应用程序

我已经给出了以下关键点:

UserPoolId: "us-east-1_dJfLT4QIp"
ClientId: "194t5jewd8o56ppmbjjlvdt6yi"
(不是真正的细节)

我可以轻松地学习本教程:

从没有AWS帐户到使用AWS Cognito登录,我不知道如何将提供的密钥集成到我的应用程序中

是否可以在我的应用程序中的某个位置设置这些密钥以访问预先存在的用户池


这是目前我拥有的最有希望的途径:

Joshua在我在medium上的演示中,我刚刚硬编码了其中的参数。但您也可以将它们以Angular的形式放入环境文件中,然后将它们映射到您正在初始化SDK的用户池对象

从“../environments/environment”导入{environment}


And you would configure the userpoolID in the environment file:

导出常量环境={ UserPoolId:'您的用户池id', ClientId:'您的客户ID' };


嗨@Ole,非常感谢你回复我。我现在就试试,让你知道。从“amazon cognito identity js”导入{CognitoUserPool};-你把它放在哪个文件中?、user-authentication.component.ts(和仪表板?)或其他不同的地方?我也能够在没有硬编码任何参数的情况下跟踪你的媒体演示,所以我不知道你是在哪里做的……我现在也写了这个问题:看看这个:

And you would configure the userpoolID in the environment file:


If these are the only keys you can pass the entire imported environment to the SDK:

    const userPool = new CognitoUserPool(environment);


I also wrote an article on how to setup Cognito using AWS Amplify and Google federated identities, so you can have a look at that an see how the amplify exports are imported:

https://medium.com/@ole.ersoy/adding-aws-cognito-federated-login-with-google-using-aws-amplify-78bf68f19c68