App Engine Java - Currently using Federated Login / Openid - how can I successfully pass an authenticated Facebook user?

I have a Java app for the Google App Engine that sings using openid / federated login.

I save the UserProfile object, which I save when we have a registered user that saves a reference to the UserService.getCurrentUser () object (and its user ID) as follows:


UserService userService = UserServiceFactory.getUserService(); user = userService.getCurrentUser(); userId = user.getUserId(); profile = UserProfileBin.getInstance().getByUserId(user.getUserId()); if (profile == null) { profile = new UserProfile(); profile.setUser(user); profile.setUserId(user.getUserId()); profile.setCreatedDate(new Date()); pm.makePersistent(profile); id = profile.getId().getId(); } 

...

Well, it all works fantastically. I use the openId selector and register with the application using a bunch of different openid providers. No problem.

Now I want people to use their logins on facebook, and I also have this part. I use server-side authentication flow. I can complete authorization and get an access token, and I use restFB. I can connect to the api schedule and get everything I need.

So my question is this: I do not know how best to accept this information and tell my application that someone is logged in.

I assume that Userervice.getCurrentUser () is not coming.

I see OauthService.getCurrentUser (). It would be great if it "knew" that I had a Facebook user. Then my user checks will simply be as follows:


 User user = UserService.getCurrentUser() if(user == null) { user = OAuthService.getCurrentUser(); } 

and fun on my way I would go.

However, I see no way to register my Facebook user using OAuthService or something else.

I am sure that this has been done before.

How can I do it? Is there a good way to do this, or am I looping around the sessions and creating a custom object for my Facebook user and sticking to it in the session and starting the filter?

+6
java google-app-engine login facebook oauth
source share
1 answer

You will need to turn on the sessions and save the relevant information about the user entering the session. You may be able to configure these settings so that session data is not downloaded for users who are logged in using OpenID. I am not sure, however, because I am not too familiar with Java.

+3
source share

All Articles