What is the best practice to use Oauth2, React, Node.js and Passport.js to authenticate user with Google sign on button?

后端 未结 3 1397
长发绾君心
长发绾君心 2020-12-30 10:41

I want to have a login button in my website so when a user clicks on it, the user can use their Google credentials. I\'d like to ideally perform the authentication server si

3条回答
  •  被撕碎了的回忆
    2020-12-30 11:18

    Redux can really help with achieving this and this follows the same logic as Nick B already explained...

    1. You set up oauth on the server side and provide an endpoint that makes that call
    2. You set up the button on you react frontend and wire that through an action to the endpoint you already setup
    3. The endpoint supplies a token back which you can dispatch via a reducer to the central redux store.
    4. That token can now be used to set a user to authenticated

    There you have it.

提交回复
热议问题