Created
July 15, 2009 08:07
-
-
Save charroch/147576 to your computer and use it in GitHub Desktop.
OAuth access to jaiku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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