简体   繁体   English

如何使用 AWS Cognito 与 Nodejs UI 应用程序和 Oauth 2.0 流使用护照 js?

[英]How to use AWS Cognito with Nodejs UI app and Oauth 2.0 flow using passport js?

I am stuck at finding values of authorizationURL:,tokenURL: for aws cognito passportjs auth flow.It would be helpful if I get such snippet.Trying to fetch the profile, phone and other details from aws cognito ui in the backend application.我被困在为aws cognito passportjs auth flow查找authorizationURL:,tokenURL:的值。如果我得到这样的片段会很有帮助。尝试从后端应用程序的aws cognito ui中获取配置文件、电话和其他详细信息。

passport.use(new OAuth2Strategy({
    authorizationURL: 'https://www.example.com/oauth2/authorize',
    tokenURL: 'https://www.example.com/oauth2/token',
    clientID: EXAMPLE_CLIENT_ID,
    clientSecret: EXAMPLE_CLIENT_SECRET,
    callbackURL: "http://localhost:3000/auth/example/callback"
  },
  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({ exampleId: profile.id }, function (err, user) {
      return cb(err, user);
    });
  }
));

The values for the tokenURL and authorizationURL are found in the Cognito settings in the AWS Console User Pool and Cognito documentation. tokenURL 和 authorizationURL 的值可在 AWS 控制台用户池和 Cognito 文档的 Cognito 设置中找到。

You can obtain the domain name from the Cognito config in the AWS Console under Cognito->User Pools->App Integration->Domain Name and tack on the endpoints from the documentation as follows.您可以从 AWS 控制台中 Cognito->User Pools->App Integration->Domain Name 下的 Cognito config 获取域名,并从文档中添加端点,如下所示。 For example:例如:

authorizationURL: 'https://your-domain-prefix.auth.us-east-1.amazoncognito.com/oauth2/authorize',

tokenURL: 'https://your-domain-prefix.auth.us-east-1.amazoncognito.com/oauth2/token',

Amazon AWS Documentation for Cognito Endpoints https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html Cognito 终端节点的 Amazon AWS 文档https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html

Passport Documentation: http://www.passportjs.org/docs/oauth/护照文件: http://www.passportjs.org/docs/oauth/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM