问题
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