1 package pl.org.nowoczesnapolska;
3 import java.io.UnsupportedEncodingException;
5 import oauth.signpost.OAuth;
6 import oauth.signpost.OAuthConsumer;
7 import oauth.signpost.OAuthProvider;
8 import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
9 import oauth.signpost.commonshttp.CommonsHttpOAuthProvider;
10 import oauth.signpost.exception.OAuthCommunicationException;
11 import oauth.signpost.exception.OAuthExpectationFailedException;
12 import oauth.signpost.exception.OAuthMessageSignerException;
13 import oauth.signpost.exception.OAuthNotAuthorizedException;
14 import android.util.Log;
16 public class AuthHelper {
20 private static OAuthConsumer mConsumer;
21 private static OAuthProvider mProvider;
22 private static String mCallbackUrl;
23 private static String apiURL = "http://epsilon.nowoczesnapolska.org.pl/api/";
25 public static void OAuthHelper(String consumerKey, String consumerSecret, String callbackUrl)
26 throws UnsupportedEncodingException {
27 mConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
28 mProvider = new CommonsHttpOAuthProvider(
29 apiURL+"oauth/request_token/",
30 apiURL+"oauth/access_token/",
31 apiURL+"oauth/authorize/");
32 mProvider.setOAuth10a(true);
33 mCallbackUrl = "wl://";
37 public static String getRequestToken()
38 throws OAuthMessageSignerException, OAuthNotAuthorizedException,
39 OAuthExpectationFailedException, OAuthCommunicationException {
40 String authUrl = mProvider.retrieveRequestToken(mConsumer, mCallbackUrl);
44 public static String[] getAccessToken(String verifier)
45 throws OAuthMessageSignerException, OAuthNotAuthorizedException,
46 OAuthExpectationFailedException, OAuthCommunicationException {
47 Log.d("resume", "beforetoken");
48 mProvider.retrieveAccessToken(mConsumer, verifier);
50 mConsumer.getToken(), mConsumer.getTokenSecret()