aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-20 16:00:38 +0300
committerGravatar Vitaly Takmazov2016-06-20 16:00:38 +0300
commit83a3c5f721411bc463fea4c209e6fc2537c50417 (patch)
tree2da68e2ed281fc9e61f9ac8492af12a18fe767ab
parent7db1637114eaaf36fb229999b478abc0bb3b1ab5 (diff)
update deps and scribejava usage
-rw-r--r--build.gradle4
-rw-r--r--src/main/java/com/juick/http/www/TwitterAuth.java17
2 files changed, 11 insertions, 10 deletions
diff --git a/build.gradle b/build.gradle
index b371b889..e58bf86d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -14,7 +14,7 @@ buildscript {
classpath 'com.eriwen:gradle-css-plugin:1.11.1'
classpath 'com.eriwen:gradle-js-plugin:1.12.1'
classpath 'org.akhikhl.gretty:gretty:+'
- classpath 'com.tkruse.gradle:gradle-groovysh-plugin:1.0.7'
+ classpath 'com.tkruse.gradle:gradle-groovysh-plugin:1.0.8'
}
}
@@ -60,7 +60,7 @@ dependencies {
compile 'org.slf4j:slf4j-jdk14:1.7.13'
compile 'com.ganyo:gcm-server:1.0.+'
compile 'com.notnoop.apns:apns:1.0.0.Beta6'
- compile 'com.github.scribejava:scribejava-apis:2.0.1'
+ compile 'com.github.scribejava:scribejava-apis:2.7.3'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'org.json:json:20151123'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
diff --git a/src/main/java/com/juick/http/www/TwitterAuth.java b/src/main/java/com/juick/http/www/TwitterAuth.java
index 421c6f64..ff02c28b 100644
--- a/src/main/java/com/juick/http/www/TwitterAuth.java
+++ b/src/main/java/com/juick/http/www/TwitterAuth.java
@@ -3,6 +3,7 @@ package com.juick.http.www;
import com.github.scribejava.apis.TwitterApi;
import com.github.scribejava.core.builder.ServiceBuilder;
import com.github.scribejava.core.model.*;
+import com.github.scribejava.core.oauth.OAuth10aService;
import com.github.scribejava.core.oauth.OAuthService;
import com.juick.server.UserQueries;
import org.json.JSONObject;
@@ -49,30 +50,30 @@ public class TwitterAuth {
response.sendError(403);
return;
}
- OAuthService oAuthService = new ServiceBuilder()
- .provider(TwitterApi.class)
+ OAuth10aService oAuthService = new ServiceBuilder()
.apiKey(consumerKey)
.apiSecret(consumerSecret)
.callback("http://juick.com/_twitter")
- .build();
+ .build(TwitterApi.instance());
if (request_token.isEmpty() && request_token_secret.isEmpty()
&& (verifier == null || verifier.isEmpty())) {
- Token requestToken = oAuthService.getRequestToken();
+ OAuth1RequestToken requestToken = oAuthService.getRequestToken();
String authUrl = oAuthService.getAuthorizationUrl(requestToken);
response.addCookie(new Cookie("request_token", requestToken.getToken()));
- response.addCookie(new Cookie("request_token_secret", requestToken.getSecret()));
+ response.addCookie(new Cookie("request_token_secret", requestToken.getTokenSecret()));
response.setStatus(HttpServletResponse.SC_FOUND);
response.setHeader("Location", authUrl);
} else {
if (verifier != null && verifier.length() > 0) {
- Token requestToken = new Token(request_token, request_token_secret);
- Token accessToken = oAuthService.getAccessToken(requestToken, new Verifier(verifier));
+ OAuth1RequestToken requestToken = new OAuth1RequestToken(request_token, request_token_secret);
+ OAuth1AccessToken accessToken = oAuthService.getAccessToken(requestToken, verifier);
OAuthRequest oAuthRequest = new OAuthRequest(Verb.GET, VERIFY_URL, oAuthService);
oAuthService.signRequest(accessToken, oAuthRequest);
JSONObject jsonResponse = new JSONObject(oAuthRequest.send().getBody());
String screenName = jsonResponse.getString("screen_name");
- if (UserQueries.linkTwitterAccount(sql, user, accessToken.getToken(), accessToken.getSecret(), screenName)) {
+ if (UserQueries.linkTwitterAccount(sql, user, accessToken.getToken(), accessToken.getTokenSecret(),
+ screenName)) {
response.setStatus(HttpServletResponse.SC_FOUND);
response.setHeader("Location", "http://juick.com/settings");
} else {