Twitter4J + Android: Authentication Challenge is Null Exception

让人想犯罪 __ 提交于 2019-11-29 03:33:36

I had the same problem. It turned out that if the time stamp on the oAuth call is incorrect, the server returns a 401 status error which on Android devices causes the "Received authentication challenge is null" exception to be thrown. All of the devices that were having this problem had incorrect times, and fixing the times fixed the problem.

Perhaps this is your issue as well?

I also had the same problem. First I was getting it when doing getOAuthRequestToken(). My consumer key and consumer secret were coming from .properties file, and turned out they had a trailing space, so were seen as invalid by Twitter's API.

After that, I also was getting the same 401 when doing getOAuthAccessToken(). Here, I wasn't correctly persisting and re-constructing RequestToken object.

This happened for me when I called the following twice in a row:

 requestToken = twitter.getOAuthRequestToken();
    return requestToken.getAuthorizationURL();

FIXED: I had this exception even after I fixed the date&time but when I looked in logcat at the params that twittherj sent to server the timestamp was still wrong - so I force-closed the app and after that exception was gone.

Gaurav Vashisth

I too stumbled across this problem. Check my solution in another thread Android: Twitter4J Exception (Received Authentication Challenge Is Null)

Youssef El Hemali

I had same problem and fixed it by Using Asynchronous task as I answered in the following link Android Twitter exception error :(

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