I have a website that uses Facebook authentication for logging in users. It uses the oAuth 2.0 server side flow for authentication and it all works fine.
I am now developing an iPhone application for the same website and want to allow users to sign in to the website via the iPhone application using FB authentication.The Facebook iOS SDK provides mechanisms to do the authentication using the client side flow, where in my iPhone app gets the access token.
Now to authenticate the user with my server, and also make the access token available to my server, I thought of sending this access token to my server (over https) and authenticate the user against my DB and set my own session related cookie. Is this the preferred or advised method? I need the access token on my server as I ask for offline access permission and have my webapp interact with FB user account from my server directly.
An easier option for me would be to just use the server side flow for authentication on my iPhone app too, as nothing new needs to be done and the server side code is the same for website or iPhone app. Is that possible?
I cannot use client side authentication and pass the access token to my server for authentication against my system and also to be stored for further use. The access token received for client side authentication is totally different from the server side authentication token and the two cannot be used interchangeably. I will have to use server side authentication.
One solution ( provided here - in the first comment to the question) is to use an UIWebView and simulate the server side flow. The following comment mentions the problems with this approach, that I have not been able to solve.
This has been solved by examining the URL to which the webview is redirected to after the login.
Another problem is that, my iPhone app does some client side interactions too (like FBShare, writing to a friend's wall, etc). If I use the simulated server side authentication, I will have to do another client side authentication for these interactions or take the painful approach and route even these actions through my server. The latter is definitely not preferable. How do I go about this? Can I avoid this double login as it will be very bad user experience?