User service and Facebook working together ?

0 votes
Hi, I am making a game with user challenges.

I don't want to force users to have a facebook account, so I am using UserService and BuddyService. These work just fine, but I am having difficulties figuring out how I can offer facebook login on top of that. Here are the issues that I see:

- with UserService, I am enforcing unique usernames for my players, which is good for leaderboards and buddies. But if people decide to user facebook login, I don't have a unique "understandable" username to display in leaderboards. I can add that info somewhere with StorageService, maybe...

- if a user creates an account with UserService, and later wants to connect with facebook, then he will both appear in the facebook linked accounts and user service. Isn't that cumbersome?

So I guess my question is, are there best practices to support both facebook and non facebook users (and potentially non facebook users that decide eventually to associate their facebook account to retrieve friends) ? This is a tricky subject and I believe it would help a lot of people to have a blog post or whitepaper about how to best use your services to solve this.

As an example, I believe parse.com is doing this well (ensuring every one connecting with facebook actually generates a user account), but parse lacks lots of high level services needed for games (leaderboards, buddy list ,etc...).

Tks
asked Sep 29, 2015 in App42 Cloud API-BaaS by dujardin (10 points)
edited Sep 29, 2015 by dujardin

1 Answer

0 votes
Ok, maybe I am answering my own question, but I would be happy to hear what the developers at App42 think about this:

Since my game requires unique usernames and the plan to enable facebook is mostly to make it easier to have filled buddy lists, here is my plan:

- have my users signup choosing a username/password --> create a user for all of them with UserService

- after that, propose to connect with facebook. If user chooses that, save his fbid in some kind of user profile on StorageService

- use BuddyService to manage buddy list

- if user is connected to a facebook account, build list of fbid of his friends on facebook and send them a buddyrequest after retrieving the associated username in StorageService

That way, every user user ends up being treated the same. Users with facebook have an easier way to request buddies, but that's about it.

What do you think of that approach?
answered Sep 29, 2015 by dujardin (10 points)
In order to enhance this query, what about if user login with Facebook account instead of entering username and password. For these kind of scenario, you have to write some custom logic which will do manage all this things. Please have a look at this sample project(https://github.com/HimanshuSShephertz/SocialInfo) which will help you to achieve the same process. Let me elaborate this in details:

For registering your user using userName/password, you can directly use user service and save some meta info of that user like his display name, his age etc in Storage service. This meta info, will help you on the UI part where you want to show the records like leaderboard and all. Once you have done with user creation, you will get the session id in the success of method call. Use that session id in service instance while saving the user score and document in Storage service.
 
Once you have done with user creation using User Management service and you want to link his Facebook account, use the custom code which I shared in the above comment. This custom code take facebook accesstoken as input and after that he will fetch the user information from Facebook. After the success of information fetched from Facebook, custom code will check that user exist in the user management or not. If it is not then it will create new user using the email address and save his meta information in Storage service and return his profile details in success of custom code call. If it exist in the data base, then he will update the meta info of that user inside custom code and return user session id along with profile details.
   
Here in both ways, you have the common thing which is session id of user. Based on the session id, you can check the session of user in App. If session id not exist, than user is not logged in the App.

Please check and let me know if it helps.

P.S Above custom code will take some information from you, like your API/Secret/Admin key, your data base name, collection name and email address from which you want to send email to user who is going to register using Facebook access token. Because this custom code, will send email to user which contain his login details.

Regards,
Himanshu Sharma
Himanshu,

We were trying to use the FBService you mentioned, but there are scenarios where user's FB account might not have email addresss. What should be done in that case?
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...