簡體   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?

我被困在為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);
    });
  }
));

tokenURL 和 authorizationURL 的值可在 AWS 控制台用戶池和 Cognito 文檔的 Cognito 設置中找到。

您可以從 AWS 控制台中 Cognito->User Pools->App Integration->Domain Name 下的 Cognito config 獲取域名,並從文檔中添加端點,如下所示。 例如:

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',

Cognito 終端節點的 Amazon AWS 文檔https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html

護照文件: http://www.passportjs.org/docs/oauth/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM