Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 640
bakua Avatar asked Mar 10 '13 15:03

bakua


People also ask

Does Facebook use WebView?

Deprecating Facebook Login support on Android WebViewsBeginning October 5, 2021, Facebook Login will no longer support using Android embedded browsers (WebViews) for logging in users.

How do I verify my Facebook login backend?

You can simply request https://graph.facebook.com/me?access_token=xxxxxxxxxxxxxxxxx if you get an error, the token is invalid. If you get a JSON object with an id property then it is valid. Unfortunately this will only tell you if your token is valid, not if it came from your app.


2 Answers

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

like image 66
bakua Avatar answered Sep 23 '22 15:09

bakua


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.

like image 43
Hugo Gresse Avatar answered Sep 20 '22 15:09

Hugo Gresse