Retrieving auth token for facebook account configured in mobile via account manager in android

笑着哭i 提交于 2020-01-25 07:43:05

问题


I am trying to get Auth token for a facebook account configured in device via account manager in android using

accountManager.getAuthToken(account,"user_activities",null,Hellol10n.this, new   GetAuthTokenCallback(), null);// account is of type "com.facebook.auth.login"

But i dont get any result. The callback is not getting invoked at all.

Does facebook support this way of getting auth token. Facebook do use oauth2. So have a look at

This lesson demonstrates connecting to a Google server that supports OAuth2. Although Google services are used as an example, the techniques demonstrated will work on any service that correctly supports the OAuth2 protocol."

http://developer.android.com/training/id-auth/authenticate.html

Also, i am trying this becoz i dont want the user to type in the credentials for an account he has already configured in the device to make the user experience simple.

UPDATE:

Also account manager has a fb account of type "com.sec.android.app.snsaccountfacebook.account_type" even if the facebook app is not installed. Is it not possible to get the auth of this account.What is the difference between the account types "com.sec.android.app.snsaccountfacebook.account_type" and "com.facebook.auth.login" in account manager


回答1:


I would recommend using the Facebook SDK for Android instead. If the user has the Facebook app, then SSO simply switches to the app for authentication and authorization, and there's no need to reenter the username/password. If the user does not have the Facebook app, then the accountManager.getAuthToken mechanism wouldn't work anyways since Android wouldn't have the account info.



来源:https://stackoverflow.com/questions/12972760/retrieving-auth-token-for-facebook-account-configured-in-mobile-via-account-mana

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!