小编Nar*_*han的帖子

Google 使用自定义登录表单登录 Cognito

目前,我正在尝试使用Cognito Aws Service为我的网络应用程序实现社交登录。但我不想将用户重定向到 Cognito托管 UI进行社交登录。

所以我使用react-google-login作为Google登录,并且我也获得了回调访问令牌

<GoogleLogin
   clientId="xxxxxxxxxxxxxx.apps.googleusercontent.com"
   buttonText="Login"
   onSuccess={this.responseGoogle}
   onFailure={this.responseGoogleFailure}
   cookiePolicy={'single_host_origin'}
/>


responseGoogle = async (response) => {
  console.log("response..........", response);
  const user = {
    name: response.profileObj.name,
    email: response.profileObj.email
  };

  let expires_at = 3600 * 1000 + new Date().getTime()

  Auth.federatedSignIn('google', { token: response.tokenId, expires_at }, user).then(credentials => {
     console.log(credentials);
  });
}
Run Code Online (Sandbox Code Playgroud)

上面的代码给出了 Cognito 会话值,但不会在用户池中创建用户。

我进行了很多搜索,但没有找到任何解决方案。我已经在下面的链接中提到了它涉及我的问题。基本上我不想为 SocialLogin 使用托管 UI。

预先感谢

https://github.com/aws-amplify/amplify-js/issues/1316

https://github.com/aws-amplify/amplify-js/issues/3875

javascript node.js reactjs amazon-cognito aws-amplify

9
推荐指数
1
解决办法
3028
查看次数