authenticationflaskvue.jsgoogle-signinflask-jwt

Authentication with Vue.js | Flask-RESTful and Google Sign-In


I am still a newcomer to both the Vue.js as well as the Flask framework. I have created a simple todo app that consumes JSON endpoints from Flask and uses Vue.js to display the UI.

My app has a TODO, PROJECT and USER model. I have successfully implemented a "normal login" through my own user model. The flow for this one:

  1. The user fills in username and password.
  2. POST request to Flask API that saves the user with a hashed password in the database.
  3. The user can log in through an /auth endpoint and receives a JSON web token in return.
  4. When the user logs out, the token is destroyed.

Now I want to implement a google sign in along with the existing user model. I could successfully create a call to the google API and have retrieved the user data from google in the vue.js client. But this is where I am stuck.

As I am very concerned about building safe applications in the future, I would like to really understand what the best practice in such a situation is.

Thanks for your help!


Solution

  • For anyone interested in this topic: I ended up saving all users in the same database table and created a boolean whether the user was logged in with a password/username or with an OAuth provider. If so, the provided token could be used to verify the user.