3
votes

I'm working on a Unity project for iOS and Android. We are using Parse as backend service, and would like to allow users to login to their Parse account through Facebook.

I'm using: Parse Unity SDK (v1.2.12), Facebook Unity SDK (v4.3.6) and Unity (v4.3.2f1)

I've got a Parse backend running, and I've set up my facebook app as described in their documentation. So I created a Parse user (ParseUserA), and I made a facebook test user (FacebookUserA). Through a iOS build of my Unity project I was able to link FacebookUserA to ParseUserA, and from this point forth FacebookUserA's accessToken can log this user in, as intended. This works, but there's an issue.

Now FacebookUserA's sister (FacebookUserB) would like to try the game. However she of course would like to have her own backend user. This should not be a problem as it is possible to create a new Parse user through facebook. But the issue is that my iOS device already has an accessToken for FacebookUserA, and it insists on using this accessToken as long as its deemed vaild.

I went to facebook.com on my iOS device (I don't have any Facebook app on this device) and I logged my test user FacebookUserA out. Then I logged in with my other test user FacebookUserB. I then launched my unity app, and it still fetches the ParseUserA information using the accessToken for FacebookUserA despite the fact that FacebookUserB now is the person logged into facebook on the device.

I know that I still have the accessToken for FacebookUserA, but how can I check that this user is actually still logged into facebook on my device? I don't want to ever auto-login using facebook if the owner of the access token is no longer logged into facebook.com. And of course if another user is logged into facebook on the device, when attempting to use the access token for FacebookUserA, then that accessToken should become invalid, destroyed or something along those lines.

Update: I might add that I've found this one post from a guy that seems like he may have found a solution. I think I might ask in that thread tomorrow, if no one in here has a good suggestion. http://parse.com/questions/how-to-invalidate-a-facebook-access-token Furthermore a Google search or two suggests that this is an issue that a lot of people has had. The link I've posted here is the closest to something useful I've found. Any help in understanding it would be appreciated.

Also, I've found this that looks to me like the same issue. I don't know who the person that states that it will be looked into is, but that was v4.3.4 and I'm using v4.3.6.. So I guess that there's a chance that it is just a bug that has not yet been resolved. Still if anyone has information or ideas I'd be happy to hear about it. Unity Facebook SDK 4.3.4 - AccessToken and Login Status not cleared for previous user

2

2 Answers

0
votes

You can call FB.Logout() from the Unity SDK. This will delete the cached access token on the device.

0
votes

The only way I found to switch users was the following. This method will only be useful for those who only need to switch users for debugging purposes.

This was the steps I followed and actually worked for me.

  1. Uninstalled the FB app on the Android device
  2. Change the permissions on the login function (Unity c# code). This step is to invalidate the current access token. I dont know if there is a better way to do this.
  3. Uninstall the game from the device
  4. Try to login again on the device, and the user and password input prompts again.