简体   繁体   中英

How to get Access_Token from twitter in android?

I have some code and its work to login or logout ,but I want to get access_tonken and store it in database.

my code:

private void onTwitterClick() {

    if (mTwitter.hasAccessToken()) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);

        builder.setMessage("Delete current Twitter connection?").setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                mTwitter.resetAccessToken();
                mTwitterBtn.setChecked(false);
                mTwitterBtn.setText("  Twitter (Not connected)");
                mTwitterBtn.setTextColor(Color.GRAY);
            }
        })
        .setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();

                mTwitterBtn.setChecked(true);
            }
        });
        final AlertDialog alert = builder.create();
        alert.show();
    } else {
        mTwitterBtn.setChecked(false);
        mTwitter.authorize();   
        // mTwitter.processToken(callbackUrl);        
    }
}

How to get access_token ?? any solution??

The access token return to your "callbackUrl" and lives short period of session time. You can not store it in your database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM