简体   繁体   中英

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. I want to learn to implement JWT with Google oauth login.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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