fernandezpablo85/scribe-java — Issue #214: Twitter Stream API: Error 401 Unauthorized
Author: wezside
Created: 2012-01-13 16:01:23+00:00
State: open

Hi,

I've modified the TwitterExample and tried to to access the Stream API for a desktop app I'm writing but keep getting a Error 401 Unauthorized. Not sure if I should post this in the Twitter dev forum as I'm using scribe-java 1.3.

As per the Stream API https://dev.twitter.com/docs/auth (bottom of page) I am using my own Access token and Access token secret and not requesting one through getAuthorizationUrl(). I have tried getAuthorizationUrl(), i.e. the normal TwitterExample with only changing the *provider* and url to use *https* but this results in the same error. Below is the code I'm using.

OAuthService service = new ServiceBuilder()
.provider( TwitterApi.SSL.class )
.apiKey("appkey")
.apiSecret("appsecret")
.build();

System.out.println("=== Twitter's OAuth Workflow ===");
System.out.println();

OAuthRequest request = new OAuthRequest( Verb.GET, PROTECTED_RESOURCE_URL );
request.addBodyParameter( "track", "android" );

Token t = new Token( token, secret );
service.signRequest( t, request );

Response response = request.send();

System.out.println("Got it! Lets see what we found...");
System.out.println();
System.out.println(response.getBody());

Any help would be appreciated.