Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Volley+oauth-signpostでOAuthリクエスト ref: http://qiita.com/PyYoshi@github/items/fe4b0a72e98852724859
RequestQueue requestQueue = Volley.newRequestQueue(context, new OAuthHurlStack(consumer)) // consumerはOAuthConsumer
public class OAuthHttpClientStack extends HttpClientStack {
private final OAuthConsumer consumer;
public OAuthHttpClientStack(HttpClient client, OAuthConsumer consumer) {
super(client);
this.consumer = consumer;
}
@Override
protected void onPrepareRequest(HttpUriRequest request) throws IOException {
super.onPrepareRequest(request);
try {
this.consumer.sign(request);
} catch (OAuthMessageSignerException e) {
// TODO: OAuthMessageSignerExceptionハンドリングを実装
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
// TODO: OAuthExpectationFailedExceptionハンドリングを実装
e.printStackTrace();
} catch (OAuthCommunicationException e) {
// TODO: OAuthCommunicationExceptionハンドリングを実装
e.printStackTrace();
}
}
}
public class OAuthHurlStack extends HurlStack {
private final OAuthConsumer consumer;
public OAuthHurlStack(OAuthConsumer consumer) {
this.consumer = consumer;
}
@Override
protected HttpURLConnection createConnection(URL url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
try {
this.consumer.sign(connection);
} catch (OAuthMessageSignerException e) {
// TODO: OAuthMessageSignerExceptionハンドリングを実装
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
// TODO: OAuthExpectationFailedExceptionハンドリングを実装
e.printStackTrace();
} catch (OAuthCommunicationException e) {
// TODO: OAuthCommunicationExceptionハンドリングを実装
e.printStackTrace();
}
return connection;
}
}

how can i pass the token to header using this volley example

rio45ka commented Jun 14, 2015

Can you give example complete for use this?
Thanx

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