I\'m trying to retrieve the AuthToken for Facebook (saved by Facebook for Android) by using the following piece of code.
AccountManager am =
Try calling AccountManager.blockingGetAuthToken
instead. If that works, then there's something more interesting at fault here...
Also, make sure your manifest has the USE_CREDENTIALS
permission set correctly.
add try { before am.getAuthToken and catch Exception where this method declaration ends.This will give you why and where excepption is happening
Why not use the Facebook SDK?
The Facebook
class in it has a member to get the OAuth 2.0 access token (if that is what you need), getAccessToken()
.
To explain the fact that neither of your logging statements are being reached, consider:
Line ~8:
am.getAuthToken(account, "com.facebook.auth.login", null, ConversationList.this,
... can return a token if it's immediately available. Maybe that's the answer you're looking for? Quoting the AccountManager documentation:
If a previously generated auth token is cached for this account and type, then it is returned. Otherwise, if a saved password is available, it is sent to the server to generate a new auth token. Otherwise, the user is prompted to enter a password.