How to login into facebook in WebView if already have access token from FB SDK in Android

bakua picture bakua · Mar 10, 2013 · Viewed 9.8k times · Source

I'm developing android app in which I have login via Facebook SDK. In app I also have facebook social comments displayed in webview. But problem is even if user is logged through fb sdk, the webview doesn't know about it and for posting new comment it requires user to login.

My question is: Is there any way how to pass login from facebook sdk session to webview? For example by some javascript function to which I give access token string and call it on webview so it gets logged in and ready for posting comments?

Thanks :)

Answer

bakua picture bakua · Mar 29, 2013

So with what I figured out to this point, there is no way how to pass loged session to WebView.

Here is my solution to this problem: At your remote server make webpage with login interface using Facebook JavaScript SDK and then display it in WebView. This way all WebViews in your app will share same login cookie and everything will work as you want.

Or you can load m.facebook.com directly, but this way it will take you to user's wall after login. Above solution offers you to display another content after login as users picture and info only (with log out button of course).

Hope it helps :)