In my application, the user opens a WebView
to the mobile versions of facebook profile page (http://m.facebook.com/some_page). My problem is that when opening the WebView
, the user is required to enter username and password for Facebook. Since I already have a Facebook access token through FB SDK, and the user might have installed the Facebook application, I assume there is some way to skip this annoying phase of signing into Facebook when opening the WebView
.
In other words, how do I use the access token that I already have in my application's WebView
?
To get the Client Access Token for an app, do the following: Sign into your developer account. On the Apps page, select an app to open the dashboard for that app. On the Dashboard, navigate to Settings > Advanced > Security > Client token.
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.
From my understanding, you can't. The access token you get for your app can only be used in conjunction with the API credentials of your App. I.e. the access token only works in calls that also contain your app's key and secret. Even if you could find a way to pass these into a WebView (which is most probably not covered by FB's Data Policies), you'd probably have to make the WebView pretend to use the Android SDK (because FB would check the call's source). That's why I suggest you can't.
You also cannot have the WebView use the user's cookies he might have in his stock browser, as each WebView has it's own context for security reasons.
If you're frequently using a WebView for FB in your app, you might be able to pull the auth cookie out of the first WebView, and then insert it into subsequent instances using CookieSyncManager. Or you could save the instance state of the first WebView and then reuse it. These are just ideas that might or might not work; I haven't checked them out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With