简体   繁体   English

如何使用 facebook 令牌或 google accesstoken 使用 nodejs 或 lambda 函数注册 AWS cognito?

[英]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/4https://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.

相关问题 如何使用 AWS Lambda (nodeJS) 查询 AWS 外部的 MySQL 数据库? - How can I query a MySQL database that is outside AWS, using AWS Lambda (nodeJS)? 如何强制 AWS Cognito:signUp() 同步执行(nodejs) - How to force AWS Cognito: signUp() to execute synchronously (nodejs) 如何在NodeJS上验证AWS Cognito访问令牌 - How to verify AWS Cognito Access Token on NodeJS 我如何使用 Azure AD 像 AWS cognito 来注册/登录用户和 api 身份验证和自定义 UI,因为我可以在 Cognito 中做到这一点? - How can i use Azure AD like AWS cognito to signup/signin users and api authentication with custom UI as i can do it in the Cognito? 如果我不使用 cognito,如何使用 Nodejs 在 axios 中准确签署 AWS elasticsearch 搜索请求? - How to exactly sign AWS elasticsearch search request in axios using Nodejs if I am not using cognito? 如何使用 nodeJs 在 AWS lambda 中获取 MediaInfo - How to get MediaInfo in AWS lambda using nodeJs 使用 AWS cognito 通过 SMS OTP 注册和登录 - Signup and Login via SMS OTP using AWS cognito 在 AWS Lambda 中使用 NodeJS 将 Woocommerce API 函数更改为异步/等待 - Change Woocommerce API functions to async/await using NodeJS in AWS Lambda 在带有 npm 的 Lambda 函数中使用 AWS Cognito - Using AWS Cognito in a Lambda function with npm 使用 AWS Lambda 删除 Cognito 用户 - Using AWS Lambda to delete a Cognito User
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM