How to retrieve an Facebook-AuthToken from the accounts saved on Android

前端 未结 4 945
春和景丽
春和景丽 2020-12-10 07:29

I\'m trying to retrieve the AuthToken for Facebook (saved by Facebook for Android) by using the following piece of code.

AccountManager am =         


        
相关标签:
4条回答
  • 2020-12-10 07:48

    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.

    0 讨论(0)
  • 2020-12-10 07:48

    add try { before am.getAuthToken and catch Exception where this method declaration ends.This will give you why and where excepption is happening

    0 讨论(0)
  • 2020-12-10 07:54

    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().

    0 讨论(0)
  • 2020-12-10 07:55

    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.

    0 讨论(0)
提交回复
热议问题