How to retrieve Twitter and facebook Authentication and Token through Android's Account Manager classes

后端 未结 3 1536
滥情空心
滥情空心 2021-02-03 10:36

I want to retrieve token via Account Manager classes. Here is sample code that works for twitter but not for facebook plz help me.

public class AccountMana         


        
3条回答
  •  北海茫月
    2021-02-03 11:15

    Call AccountManager.getAccountsByType(null) to retrieve all accounts, and check the returned account data includes the information you need. It may simply not be exposed.

    Try calling AccountManager.blockingGetAuthToken instead. Also, make sure your manifest has the USE_CREDENTIALS permission set correctly.

    You can see this discussion How to retrieve an Facebook-AuthToken from the accounts saved on Android

    But I would also suggest Facebook SDK with offline access permission(This permission makes the access token returned by the OAuth endpoint long-lived, otherwise auth token is valid only for 1 hour.)

提交回复
热议问题