Integrate Lift ProtoUser with Facebook Login / SSO
I'm writing a web-based app (hoping to using Lift) and would like to have users log into my system using their Facebook credentials. I also plan to have a user table so that I can track the users who perform action开发者_高级运维s on my site.
- If this is the first time the user has logged in, then create a new User object (extend Lift's ProtoUser), persist that user to the database, and set that user as the current user for this session.
- If this is a returning user, then retrieve the registered user from the database, and set that user as the current user for this session.
Has anyone done this type of user integration before in Lift and can provide some guidance or even source code to achieve this? Thanks.
In order to get user access token do following roughly:
- Create a Facebook app
- On your lift web create a button and when an user clicks it redirect the user to facebook ouath dialog with properly configured parameters such app_id, redirect_uri,permission ...
- After user authorizes your app it will redirect to your page with user access token. I think facebook attaches the access token in redirect url if I'm not wrong. Get the access token and you know what to do next.
This repo on github: https://github.com/dahdahm/lift_authentication_starter contains a sample that shows loggin in through facebook and openid.
精彩评论