Cognito用户池-是否可以为Facebook登录创建自定义注册/登录表格? [英] Cognito User Pools - Is it possible to create a custom sign up/in form for Facebook login?

本文介绍了Cognito用户池-是否可以为Facebook登录创建自定义注册/登录表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想将 Cognito用户池用于Facebook登录,这可以使用内置登录表单来实现,但是我需要使用自己的登录表单.

I would like to use a Cognito User Pool for Facebook logins only, which may be possible using the built in login form, but I need to use my own.

从理论上讲,当涉及到自定义表单时,这并不难:从FB接收到用户对象后,将用户和电子邮件属性绑定到我的用户池中,然后将其保存.

Theoretically, when it comes to a custom form, it shouldn't be hard: after I receive a user object from FB, I bind the user and email attributes to the ones in my User Pool and I save it.

但是如何处理密码字段和将来的身份验证?在这里,我在旅途中失败了...

But what to do about the password field and future authentication? And here I have failed during my journey...

...
userPool.signUp('FoobarUser', '**password?**', attributeList, null, function(err, result){
...

在深入研究文档的同时,我尝试实现身份池(联合身份),并设法以数据集的形式保存用户信息,但是然后我意识到,如果可能的话,查询这些集合将是一个巨大的痛苦.

While digging deeper into the docs, I tried to implement a Identity Pool (Federated Identities), managed to save user info in the form of datasets as well, but then I realised, querying these sets gonna be a huge pain if possible at all.

也许我没有理解这些概念,如果有人提出使用Cognito以一种井井有条的方式来管理Facebook登录名的方法,我将非常感激.

Maybe I'm failing to understand the concepts, I would be really thankful if someone could suggest a way to manage facebook logins in a nicely organised fashion using Cognito.

推荐答案

因此,这是我从您的查询中了解的信息.

So here is what I understand from your query.

设置

  • 将Facebook链接到userpool
  • 该应用程序客户端仅允许Facebook登录,不允许其他提供商(甚至Userpool)
  • 登录时,您希望Facebook用户的信息自动填充到您的Userpool中
  • 您不想使用Cognito的内置UI,而是使用自己的

我的2美分

  • 在您的应用客户端中,只需选择Facebook
  • 在您的UI中,有一个登录按钮.单击后,应重定向到用户池的授权端点

https://your_domain.auth.us-east-1.amazoncognito.com/oauth2/authorize?redirect_uri=https://www.example.com&response_type=token&client_id=your_appclient_id

如果要与多个提供程序一起使用自己的UI,请在Client中允许相同的操作,然后单击UI中相应的按钮(例如Facebook),将用户重定向到授权端点,但在URL中附加identity_provider

If you want to use your own UI with multiple providers, allow the same in Client and on clicking the appropriate button in your UI (say Facebook), redirect users to the authorize endpoint but append the identity_provider in the URL

如果要查看所有受支持的身份提供程序的名称,请使用

If you want to see the names of all supported identity providers, use ListIdentityProviders API call

这样,所有Facebook用户都将在您的用户池中自动创建.当然,它们的名称将是随机的,例如 Facebook_123jkjdwj ,但根据您的属性映射,将从令牌中正确填充其所有详细信息.另外,还将来自特定提供程序的所有自动创建的用户添加到自动创建的组"Userpoolid_providername"中. us_east_1_xxxx_Facebook.

This way, all Facebook users will be automatically created in your userpool. Of course, their names will be random like Facebook_123jkjdwj but all their details will be correctly populated from the token as per your attribute mapping. As a plus, all auto-created users from a particular provider are added to an auto-created group 'Userpoolid_providername' eg. us_east_1_xxxx_Facebook.

这篇关于Cognito用户池-是否可以为Facebook登录创建自定义注册/登录表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆