How to use Facebook access token in android app webview

后端 未结 3 2053
野趣味
野趣味 2021-02-07 00:10

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 <

3条回答
  •  终归单人心
    2021-02-07 00:39

    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.

提交回复
热议问题