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

后端 未结 3 1541
滥情空心
滥情空心 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:36

    You can also create intent and obtain token from facebook application

    Intent intent = new Intent();
    intent.setClassName("com.facebook.katana", "com.facebook.katana.ProxyAuth");
    intent.putExtra("client_id", apiKey);
    intent.putExtra("scope", scope);
    
    try {
        activity.startActivityForResult(intent, requestCode);
    } catch (ActivityNotFoundException e) {
        return false;
    }
    

    Then onActivityResult(int requestCode, int resultCode, Intent data) of you activity you can get the token using

    data.getStringExtra("access_token");
    

提交回复
热议问题