diff options
author | Vitaly Takmazov | 2016-06-20 16:00:38 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-06-20 16:00:38 +0300 |
commit | 83a3c5f721411bc463fea4c209e6fc2537c50417 (patch) | |
tree | 2da68e2ed281fc9e61f9ac8492af12a18fe767ab /src | |
parent | 7db1637114eaaf36fb229999b478abc0bb3b1ab5 (diff) |
update deps and scribejava usage
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/http/www/TwitterAuth.java | 17 |
1 files changed, 9 insertions, 8 deletions
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 { |