summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-04-24 18:14:02 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-04-25 01:40:09 +0200
commit33c8daf172561f6bd303b2290f44bb02c329a022 (patch)
tree3f07a5c1b05d38d2fa6be0ba7fcaa6d34167ac86
parent59cdab873e09fb8cc0e0fd8d40548afe9ed59a25 (diff)
downloadTwitterDataAnalytics-33c8daf172561f6bd303b2290f44bb02c329a022.tar.gz
Pair the OAuth access token and secret
-rw-r--r--src/mining/OAuthRequester.java8
-rw-r--r--src/support/OAuthAccessTokenSecret.java28
2 files changed, 33 insertions, 3 deletions
diff --git a/src/mining/OAuthRequester.java b/src/mining/OAuthRequester.java
index d72ca2f..d3215c6 100644
--- a/src/mining/OAuthRequester.java
+++ b/src/mining/OAuthRequester.java
@@ -9,6 +9,7 @@ import oauth.signpost.basic.DefaultOAuthProvider;
import oauth.signpost.exception.OAuthException;
import org.json.JSONObject;
import support.ConsumerKeySecret;
+import support.OAuthAccessTokenSecret;
import utils.Configuration;
/**
@@ -48,10 +49,11 @@ public class OAuthRequester extends AbstractRequester {
* https://dev.twitter.com/docs/auth/tokens-devtwittercom) or via a PIN
* (https://dev.twitter.com/docs/auth/pin-based-authorization).
*
- * @param token Access token.
- * @param secret Access token secret.
+ * @param secrets Access token and token secret.
*/
- public void setAccessToken(String token, String secret) {
+ public void setAccessToken(OAuthAccessTokenSecret secrets) {
+ String token = secrets.getToken();
+ String secret = secrets.getSecret();
consumer.setTokenWithSecret(token, secret);
}
diff --git a/src/support/OAuthAccessTokenSecret.java b/src/support/OAuthAccessTokenSecret.java
new file mode 100644
index 0000000..795b036
--- /dev/null
+++ b/src/support/OAuthAccessTokenSecret.java
@@ -0,0 +1,28 @@
+package support;
+
+/**
+ * Contains an OAuth token and secret pair. These tokens can be retrieved from
+ * dev.twitter.com (https://dev.twitter.com/docs/auth/tokens-devtwittercom) or
+ * by querying the user for a specific PIN. See {@link mining.OAuthRequester}
+ * for the latter method.
+ *
+ * @author Peter Wu
+ */
+public class OAuthAccessTokenSecret {
+
+ private final String token;
+ private final String secret;
+
+ public OAuthAccessTokenSecret(String token, String secret) {
+ this.token = token;
+ this.secret = secret;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public String getSecret() {
+ return secret;
+ }
+}