twitter connection failed

Bhavesh Jethani picture Bhavesh Jethani · Mar 7, 2014 · Viewed 7.1k times · Source

In Android,
Twitter connection failed. SSL is required?

My code was working perfectly and it is currently a live application. However, since 2014 it hasn't been working and I've heard that Twitter has applied https or using SSL concept.

help me to solved this issue.

Here is my log.

 03-14 15:00:02.838: D/TwitterApp(697): Error getting access token
03-14 15:00:02.878: W/System.err(697): 403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
03-14 15:00:02.878: W/System.err(697): message - SSL is required
03-14 15:00:02.878: W/System.err(697): code - 92
03-14 15:00:02.878: W/System.err(697): Relevant discussions can be found on the Internet at:
03-14 15:00:02.878: W/System.err(697):  http://www.google.co.jp/search?q=6f0f59ca or
03-14 15:00:02.888: W/System.err(697):  http://www.google.co.jp/search?q=20d0f73f
03-14 15:00:02.888: W/System.err(697): TwitterException{exceptionCode=[6f0f59ca-20d0f73f], statusCode=403, message=SSL is required, code=92, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=14, limit=15, resetTimeInSeconds=1394790328, secondsUntilReset=-18874}, version=3.0.3}
03-14 15:00:02.888: W/System.err(697):  at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.TwitterBaseImpl.fillInIDAndScreenName(TwitterBaseImpl.java:126)
03-14 15:00:02.888: W/System.err(697):  at twitter4j.TwitterImpl.verifyCredentials(TwitterImpl.java:592)
03-14 15:00:02.908: W/System.err(697):  at com.twitter.android.TwitterApp$3.run(TwitterApp.java:150)

twitter connection code. http://www.androidhive.info/2012/09/android-twitter-oauth-connect-tutorial/ this is a develop

Answer

richhallstoke picture richhallstoke · Mar 14, 2014

To my knowledge nothing much has changed with the OAuth implementation that would cause this, however, after you have authenticated using OAuth if you were then using non-SSL requests for data this may have worked previously but would not now. Twitter introduced a change restricting access to SSL/TLS connections only on January 14th 2014.

Somewhere in your Java code there will be URL's that are being used to retrieve data from Twitter's servers. I would suggest you do a search/replace through your code, where for any occurrences of http://api.twitter.com/ you replace them with https://api.twitter.com/ and this may hopefully solve this issue. It's possible there are other issues that may come to light afterwards but at least this is your first step.

By specifying https this makes sure you are using SSL protocol to ensure data is kept secure during transmission between your application and Twitter.

If you need more information to optionally validate and verify the SSL certificate in your code for additional security, then read Connecting to Twitter API via SSL on Twitter's developers documentation website.


Edit: Just to clarify further, in order to receive this error message you must have successfully authenticated using OAuth via an SSL URL, but then reverted to non-SSL URL's for follow-on data requests.