Created
June 29, 2013 00:24
-
-
Save julianshen/5889097 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.htc.blinkfeed.sample.vimeo.api; | |
import java.io.IOException; | |
import java.net.HttpURLConnection; | |
import oauth.signpost.OAuthConsumer; | |
import oauth.signpost.basic.DefaultOAuthConsumer; | |
import oauth.signpost.exception.OAuthCommunicationException; | |
import oauth.signpost.exception.OAuthExpectationFailedException; | |
import oauth.signpost.exception.OAuthMessageSignerException; | |
import oauth.signpost.http.HttpRequest; | |
import retrofit.client.OkClient; | |
import retrofit.client.Request; | |
public class SignedOkClient extends OkClient { | |
OAuthConsumer mConsumer =null; | |
public SignedOkClient(OAuthConsumer consumer) { | |
super(); | |
mConsumer = consumer; | |
} | |
@Override | |
protected HttpURLConnection openConnection(Request request) | |
throws IOException { | |
HttpURLConnection connection = super.openConnection(request); | |
try { | |
HttpRequest signedReq = mConsumer.sign(connection); | |
} catch (OAuthMessageSignerException e) { | |
//Fail to sign, ignore | |
e.printStackTrace(); | |
} catch (OAuthExpectationFailedException e) { | |
//Fail to sign, ignore | |
e.printStackTrace(); | |
} catch (OAuthCommunicationException e) { | |
//Fail to sign, ignore | |
e.printStackTrace(); | |
} | |
return connection; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try: