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

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 :)


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 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 :)

If some user still want to use facebook login page, you can try to use the android Javascript Interface to pass the access_token to the Android Facebook SDK.

You can try to pass the access_token from the native sdk to the webview via query string.

myWebView.loadUrl('' + facebookAccessToken);

And in your webview check if the access_token is set and use it with the javascript sdk, hope it helps someone with the same issue.

Facebook Rest API service is already deprecated. You can user Facebook SDK to login and access details from facebook. Check the facebook documentation.

Did you try out the tutorials in, here they clearly given how to login. Once you logged in the details of the user will be cached, if you need to publish any data you might need permission for that, so you will be directed to login activity once more. Its given in this link

Need Your Help

Receiving key press and key release events in Linux terminal applications?

linux terminal keypress ncurses tty

I would like to write a simple C program that will perform different actions based on both "key down" and "key up" events. This program will be run from inside rxvt.

How to implement a Worms style destructible terrain in XNA?

c# xna terrain

I want to prototype an idea for a game I have. The idea for this game is that the player will dig through the ground, creating tunnels and finding treasure.