[英]How can I signup with AWS cognito using facebook token or google accesstoken using nodejs or lambda functions?
I am trying to add AWS Cognito with Google and Facebook login.我正在尝试使用 Google 和 Facebook 登录添加 AWS Cognito。 Somehow the current plugins are available not working with my current setup and I am not able to get it working for a few days now.
不知何故,当前的插件无法使用我当前的设置,而且我现在几天都无法使用它。 After adding multiple bug https://github.com/agnostech/flutter_amplify/issues/4 and https://github.com/furaiev/amazon-cognito-identity-dart-2/issues/42 with no help so far.
在添加多个错误https://github.com/agnostech/flutter_amplify/issues/4和https://github.com/furaiev/amazon-cognito-identity-dart-2/issues/42 之后,到目前为止没有任何帮助。 So I thought to make a get/post request to lambda with the access token (As I am login with Facebook and google but not able add a user to Cognito) and that would add the user.
因此,我想使用访问令牌向 lambda 发出获取/发布请求(因为我使用 Facebook 和 google 登录但无法将用户添加到 Cognito),这将添加用户。
AWS.config.region = 'us-XXXXXXX-1';
// Add the Google access token to the Cognito credentials login map.
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-XXXX-1:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
RoleArn: 'arn:aws:iam::XXXXXXXX:role/Cognito_XXXXXXXXXUnauth_Role',
Logins: {
'accounts.google.com': authResult['id_token']
}
});
I am following this AWS Cognito + google signup but is there a better way to do this on the current date?我正在关注此AWS Cognito + google 注册,但在当前日期有更好的方法吗? Also each time user logins will it try to add the user to Cognito?
此外,每次用户登录时,它是否会尝试将用户添加到 Cognito? Considering we have only one button for sign it or sign up.
考虑到我们只有一个按钮来签名或注册。
Thanks in advance.提前致谢。
I just read this guide to have google auth with cognito.我刚刚阅读了本指南,以使用 Cognito 进行 google 身份验证。 https://docs.aws.amazon.com/cognito/latest/developerguide/google.html
https://docs.aws.amazon.com/cognito/latest/developerguide/google.html
It is quite simple, you have to login with google using regular way, as soon as you receive access token from google you pass it to cognito.这很简单,您必须使用常规方式使用 google 登录,一旦您收到来自 google 的访问令牌,您就将其传递给 cognito。
logins.put("accounts.google.com", token); credentialsProvider.setLogins(logins);
Package way,包装方式,
There is a plugin for this, Look at the one of the use cases in the guide here.有一个插件,在这里查看指南中的用例之一。 https://pub.dev/packages/amazon_cognito_identity_dart_2
https://pub.dev/packages/amazon_cognito_identity_dart_2
Quoting the doc引用文档
Use case 19. Using this library with Cognito's federated sign in on mobile devices.用例 19.在移动设备上将此库与 Cognito 的联合登录一起使用。 Use
flutter_webview
( https://pub.dev/packages/webview_flutter ) to navigate to Cognito's authorize URL.使用
flutter_webview
( https://pub.dev/packages/webview_flutter ) 导航到 Cognito 的授权 URL。 Use flutter_webview's navigationDelegate to catch the redirect to myapp://?code=<AUTH_CODE>
.使用 flutter_webview 的 navigationDelegate 捕获重定向到
myapp://?code=<AUTH_CODE>
。 Make a POST
request to Cognito's token URL to get your tokens.向 Cognito 的令牌 URL 发出
POST
请求以获取您的令牌。 Create the session and user with the tokens使用令牌创建会话和用户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.