Facebook OAuth API - how to add Facebook integration into your desktop game (+source)

Hi all, I’ve been trying to use the new Facebook OAuth API inside a Unity desktop game and it took me a while to get a viable working solution so I thought I’d share it with the community: http://www.ifc0nfig.com/accessing-facebook-within-unity/.

It’s just a short guide on how to get set-up and I’ve included my Unity + Visual Studio projects for you to take a look at. Here’s a video demonstrating it: http://www.youtube.com/watch?v=sT1iHX2cxyA

I hope it’s of use to somebody.

Thanks a lot! I posted a thread a while ago asking if some form of OpenID/OAuth as a login system for a desktop game was possible.
http://forum.unity3d.com/threads/59580-OpenID-login-authentication-for-Unity-applications?highlight=oauth

Your solution looks like it’s getting very close. It might need some automation to get the login a bit more seamless, although if I’m not mistaken, a token can last as long as a user likes (when “stay connected” is enabled), which is much more convenient than having to re-do the process for every login.

Awesome work.

Thanks werewraith, just wanted to give something back to the community! Do you have any thoughts on how to do the authentication automatically? The only option I can think of is using the htmlTexture but it doesn’t seem to work with Unity Indie/3 yet :frowning:

The best -working- login example I can think of is realXtend, an open source spin-off of the SecondLife virtual world. It uses OpenID for login through what seems to be a browser emulation inside the standalone application (Including HTTPS connections and such).
http://www.realxtend.org
Perhaps browsing through its source would give you a better idea of how it works.

For Unity, I am aware there is a browser emulation in the works (Berkelium), but I have no idea what it supports when it comes to secure connections. http://forum.unity3d.com/threads/53536-Berkelium-plugin-rendering-interactive-websites

Those two examples could prove useful in improving your OAuth solution.

Indeed, Berkelium looks very very handy and as soon as there is a Windows port I’ll update this lib :slight_smile:

Of Berkelium? There’s mac and pc, someone is helping at the moment with the mac version

I’ve managed to get this working without any user interaction, check it out: http://www.ifc0nfig.com/accessing-facebook-unity-game-2/

Is this solution always working ?

does it work for android and ios too?

I downloaded sample project from http://www.ifc0nfig.com/accessing-facebook-unity-game-2/ .

But it showing error SerializationException: Invalid JSON string

Return url is not return any access token value

Hi,

I’m also interested into connecting my desktop app to Facebook, and I’ve downloaded the eth0izzle solution however it doesn’t work for me either. Any other ideas on how to do this?

Obviously, the best solution would be to connect directly through Unity Destkop app, but as an alternative could we maybe create a web app through which users can connect to Facebook - the web app would collect all the required information from Facebook - and then Unity Desktop app could connect to that web app and use that information? Does anybody see any possible problems with this approach?

Thank you.