简体   繁体   English

如何将Json Web Token(JWT)和Google oauth结合使用passwordjs,passport-google-oauth和node来创建社交登录系统?

[英]How to combine Json Web Token(JWT) and google oauth using passportjs, passport-google-oauth and node to create social login system?

I need a working example tutorial. 我需要一个工作示例教程。 I understand the concept of JWT well. 我非常了解JWT的概念。 I want to learn to implement JWT with Google oauth login. 我想学习用Google oauth登录实现JWT。

I can't find any concise, clear, and complete tutorial. 我找不到任何简明,清晰和完整的教程。 Please refer me books, tutorials, or examples. 请参考我的书籍,教程或示例。

参考资料说明了您想使用node和express来实现的所有内容

The basic work-flow : 基本工作流程

first when the user login you generate a token consisted of specific signature for example a string of hashed ( user_id + 'random_string' ) and save it into your database. 首先,当用户登录时,您会生成一个由特定签名组成的令牌,例如一个哈希字符串(user_id +'random_string'),并将其保存到数据库中。

then send the generated token with header for example 然后发送带有标题的生成令牌,例如

'x-auth': generatedToken

after that whenever user makes a request you need to check for the request's header if it contains 'x-auth' header if so you check if this 'x-auth' matches the one in your database. 此后 ,每当用户发出请求时,您都需要检查请求的标头(如果它包含“ x-auth”标头),因此,您需要检查此'x-auth'与数据库中的标头匹配。

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

相关问题 ExpressJS + PassportJS + passport-google-oauth `req.isAuthenticated()` 登录后立即返回 false - ExpressJS + PassportJS + passport-google-oauth `req.isAuthenticated()` returning false immediately after login 使用Passport-google-oauth的OAuth2:GET请求中没有正文,但我仍然收到一些令牌 - OAuth2 using passport-google-oauth: there is no body in GET request but I still recieve some token Passport-Google-OAuth 回调在 Web 服务中使用时不起作用 - Passport-Google-OAuth Callback Not working when used in Web Service 护照谷歌oauth无法注销用户 - passport-google-oauth unable to logout user Passport-Google-OAuth回调无法正常工作 - Passport-Google-OAuth Callback Not working 使用passport-google-oauth和react-native - Using passport-google-oauth with react-native Passport-google-oauth和passport-google-token有什么区别? - What is the difference between passport-google-oauth and passport-google-token? 如何使用passport-google-oauth成功验证后重定向到原始页面 - how to redirect to original page after successful authentication using passport-google-oauth passport-google-oauth 无法获取用户配置文件 ECONNRESET - passport-google-oauth Failed to fetch user profile ECONNRESET 缺少必需参数:带有 passport-google-oauth 的 redirect_uri - Missing required parameter: redirect_uri with passport-google-oauth
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM