Twitter connectivity in cloud

oauth
api

#1

Our app connects to twitter using twitter4j api. We have no connectivity problem when running in local machine. But, when we try to deploy the same application in cloud(IBM bluemix), I get 401 could not authorize. My consumer key, secret is working and system clock is in sync and have UTC timezone. Strange thing is, connection worked in cloud for around 6hrs and then the same exception started.

Do I need to add any extra configuration to get this work in cloud? I checked API and could not find any. Please suggest.


#2

Which endpoints are you connecting to? Do you receive any other error code from the API?

Remember that the streaming API only allows a limited number of connections per app token and IP address, so if you are attempting to run multiple copies of an app you may see this kind of error.


#3

The only exception we see is this,

401:Authentication credentials (https://dev.tw itter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.

My configuration is like this,

<bean id="configFactory" class="twitter4j.conf.ConfigurationBuilder">
	<property name="debugEnabled" value="true" />
	<property name="OAuthConsumerKey" value="${twitter.consumerKey}" />
	<property name="OAuthConsumerSecret" value="${twitter.consumerSecret}" />
	<property name="prettyDebugEnabled" value="true" />
	<property name="MBeanEnabled" value="true" />
	<property name="includeEntitiesEnabled" value="false" />
    <property name="tweetModeExtended" value="true"/>
 </bean>
<bean id="twitterConfig" factory-bean="configFactory"
	factory-method="build" />

<bean id="twitterFactory" class="twitter4j.TwitterFactory">
	<constructor-arg name="conf" ref="twitterConfig" />
</bean>

<bean id="accessToken" class="twitter4j.auth.AccessToken">
	<constructor-arg name="token" value="${twitter.token}" />
	<constructor-arg name="tokenSecret" value="${twitter.tokenSecret}" />
</bean>

<bean id="twitter" factory-bean="twitterFactory" factory-method="getInstance">
	<constructor-arg name="accessToken" ref="accessToken" />
</bean>

I am just trying to get twitter instance.


#4

Have you tried creating a new Twitter app and testing those credentials to make sure it’s not an issue with your current app?


#5

I tried creating a new Twitter app, it did not work.