简体   繁体   English

使用护照实施Oauth 2.0身份验证机制

[英]Implement Oauth 2.0 authentication mechanism using passport

我需要使用护照在我的node js应用中实现Oauth 2.0。但是,护照中的Oauth 2.0文档不包含架构定义和用户注册以及刷新令牌.node js中是否有带有护照的Restful API实现,类似于Laravel中的身份验证机制。

For REST API implementation with Node.js and passport.js oAuth 2.0, you can refer to this article. 对于Node.js的REST API的实现和passport.js的OAuth 2.0,你可以参考这个文章。 For more information, you can refer to this StackOverflow question. 有关更多信息,您可以参考此StackOverflow问题。

Use passport-oauth2 for this, 为此,请使用passport-oauth2,

npm install passport-oauth2 npm安装通行证-oauth2

 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); }); } )); 

For more details refer Here 有关更多详细信息,请单击此处

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

相关问题 使用Passport JS的自定义策略Oauth身份验证 - Custom strategy Oauth authentication using Passport JS 尝试实现Linkedin Oauth2.0完整身份验证流程 - Trying to implement Linkedin Oauth2.0 full authentication flow 使用Passport和OAuth2 +社交网络进行NodeJS REST身份验证 - NodeJS REST authentication using Passport and OAuth2 + social network Node.js 通行证 OAuth 2.0 身份验证:存储访问和刷新令牌的位置 - Node.js passport OAuth 2.0 authentication: where to store access and refresh tokens OAuth 2.0身份验证和授权 - OAuth 2.0 Authentication and Authorization Passport.js OAuth 2.0使用承载 - Passport.js OAuth 2.0 to use bearers 使用Passport js进行身份验证 - Authentication Using Passport js 使用nodejs护照多个OAuth2.0方法登录到同一个帐户 - Using nodejs passport for multiple OAuth2.0 methods to login to the same account 使用OAuth 2.0a API向LinkedIn进行身份验证的护照策略在保存用户时返回未定义的电子邮件 - Passport strategy for authenticating with LinkedIn using the OAuth 2.0a API return undefined email on save User 如何使用 OAuth 2.0 API 使用 Google 访问令牌通过 Passport 正确进行身份验证? - How to correctly authenticate through Passport with Google access tokens using the OAuth 2.0 API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM