xAuth Authentication for Twitter Share in Android?

岁酱吖の 提交于 2019-12-20 04:19:41

问题


I am working on the Twitter Authentication. The Basic Authentication will expire on August 16th onwards. So we have to use OAuth to use Twitter Authentication. But Its some Complicated to implement. XAuth is cuts off the two steps. But the Problem is i used Twitter4j to authenticate.And also had bad documentation too. I want to use XAuth from 1.6 itself. Which package you suggest to use. and If any example or tutorial for specifiacally for Android to use XAuth Authentication.


回答1:


EDIT: In my code I did this:

System.setProperty("twitter4j.oauth.consumerKey", "your token");
System.setProperty("twitter4j.oauth.consumerSecret", "your token secret");

Twitter twitter = new TwitterFactory().getInstance(login, password);

AccessToken accessToken = twitter.getOAuthAccessToken();

Then you must save your Token and Token secret from AccesToken

if (mAccessToken != null) {
    if (mAccessToken.getToken() != null && mAccessToken.getTokenSecret() != null) {
        saveAccessToken(mAccessToken.getToken(), mAccessToken.getTokenSecret());
    }
}

When you want to use your Token you just do this:

TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);


来源:https://stackoverflow.com/questions/3280328/xauth-authentication-for-twitter-share-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!