Reputation: 115
I have 2 node apps. First is simple RESTfull CRUD API for Mongo DB. Second is Backbone app with Google OAuth 2 access in server (for that I use passport.js).
I want to store authenticated users in Mongo DB collection with some additional information, like role or grantAccess field. First app must check if that users have access to data.
The question is how can I pass information about user to my API, what information I need to send? Could I send hashed copy of oauth token and then compare it with hashed filed from DB or another information? What is the best approach in this case?
Many thanks.
Upvotes: 0
Views: 374
Reputation: 2221
There is two options:
Implement oauth2 on your server.
Store on your google access token on your backbone, then on every request send the access token to your restful crud. On the server get the id of the owner of the access token, query your mongodb for the user that have the google id registered, and get their premissions.
I've use this approach to auth my app (but with facebook), because you could trush on the response of facebook or google, I think.
Upvotes: 1