How to use Facebook access token in android app webview

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?

Answers


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.


You can store that AccessToken separately in Properties and check if you use webview then pass that accessToken and when user use Ti.Facebook then use another AccessToken.


Read this project carefully and try...I tried this example in my project ..It works..

Bu before you taking this example, You have to create a page in facebook and get an application-id, to use in this project

https://github.com/ddewaele/AndroidFacebookSample


Need Your Help

Should I ping mysql server before each query?

php mysql ping

So I was wondering whether I should or should not ping the mysql server (mysqli_ping) to ensure that the server is always alive before running query?