Skip to content

Instantly share code, notes, and snippets.

@krrrr38
Created December 27, 2013 00:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krrrr38/8140942 to your computer and use it in GitHub Desktop.
Save krrrr38/8140942 to your computer and use it in GitHub Desktop.
volley + signpost
import com.android.volley.toolbox.HurlStack;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class OAuthStack extends HurlStack{
private final OAuthConsumer consumer;
public OAuthStack(OAuthConsumer consumer) {
this.consumer = consumer;
}
@Override
protected HttpURLConnection createConnection(URL url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
try {
consumer.sign(connection);
} catch (OAuthMessageSignerException e) {
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
e.printStackTrace();
} catch (OAuthCommunicationException e) {
e.printStackTrace();
}
return connection;
}
}
// OAuthConsumer consumer = ~
// RequestQueue queue = Volley.newRequestQueue(this.getActivity(), new OAuthStack(consumer));
@lucasxas
Copy link

Nicely done 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment