Skip to content

Instantly share code, notes, and snippets.

@charroch
Created July 15, 2009 08:07
Show Gist options
  • Save charroch/147576 to your computer and use it in GitHub Desktop.
Save charroch/147576 to your computer and use it in GitHub Desktop.
OAuth access to jaiku
import net.oauth.OAuthAccessor;
import net.oauth.OAuthConsumer;
import net.oauth.OAuthServiceProvider;
import net.oauth.client.OAuthClient;
import net.oauth.client.httpclient4.HttpClient4;
public class Main {
public static void main(String[] args) throws Exception {
String consumerKey = "<KEY>";
String callbackUrl = null;
String consumerSecret = "<PRIVATE>";
String reqUrl = "http://jaiku.com/api/request_token";
String authzUrl = "http://jaiku.com/api/authorize";
String accessUrl = "http://jaiku.com/api/access_token";
OAuthServiceProvider provider = new OAuthServiceProvider(reqUrl,
authzUrl, accessUrl);
OAuthConsumer consumer = new OAuthConsumer(callbackUrl, consumerKey,
consumerSecret, provider);
OAuthClient client = new OAuthClient(new HttpClient4());
OAuthAccessor accessor = new OAuthAccessor(consumer);
client.getRequestToken(accessor);
System.out.println("go to and authorize:");
System.out
.println(accessor.consumer.serviceProvider.userAuthorizationURL
+ "?oauth_token=" + accessor.requestToken
+ "&perms=PERMISSION");
Thread.sleep(15000);
System.out.println("continuing");
client.getAccessToken(accessor, "POST", null);
System.out.println("Access token:" + accessor.accessToken);
System.out.println("Request token:" + accessor.requestToken);
System.out.println("Token Secret:" + accessor.tokenSecret);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment