Skip to content

Instantly share code, notes, and snippets.

@smaspe
Created June 6, 2013 09:04
Show Gist options
  • Save smaspe/5720280 to your computer and use it in GitHub Desktop.
Save smaspe/5720280 to your computer and use it in GitHub Desktop.
final class TokenRequest extends StringRequest {
TokenRequest(int method, String url, Listener<String> listener,
ErrorListener errorListener) {
super(method, url, listener, errorListener);
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("grant_type", "client_credentials");
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
String auth = "Basic "
+ Base64.encodeToString((TwitterValues.CONSUMER_KEY
+ ":" + TwitterValues.CONSUMER_SECRET).getBytes(),
Base64.NO_WRAP);
headers.put("Authorization", auth);
return headers;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment