Nar*_*han 9 javascript node.js reactjs amazon-cognito aws-amplify
目前,我正在尝试使用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。
预先感谢
小智 6
可以直接打开到 Google 登录页面的链接,而不显示托管 ui,但仍然通过 Cognito 进行身份验证,基本上直接链接到在 Cognito 托管 ui 中选择 Google 按钮时打开的 url
https://<YOUR_DOMAIN>.auth.<REGION>.amazoncognito.com/oauth2/authorize?identity_provider=Google&redirect_uri=<REDIRECT_URI>&response_type=TOKEN&client_id=<CLIENT_ID>&scope=openid
Run Code Online (Sandbox Code Playgroud)
身份验证后,您将返回重定向 uri,并且用户将被创建/身份验证。
| 归档时间: |
|
| 查看次数: |
3028 次 |
| 最近记录: |