Skip to content

Instantly share code, notes, and snippets.

@smaspe
Last active December 18, 2015 14:19
Show Gist options
  • Save smaspe/5796296 to your computer and use it in GitHub Desktop.
Save smaspe/5796296 to your computer and use it in GitHub Desktop.
DelegatingRequest<JSONObject> tokenRequest = new DelegatingRequest<JSONObject>(
Method.POST, TOKEN_URL, NewtorkResponseParser.jsonObjectParser,
new Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
ACCESS_TOKEN = response.optString("access_token");
// Do the rest of the treatment
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error during request");
error.printStackTrace();
}
});
String auth = "Basic "
+ Base64.encodeToString(("<CONSUMER_KEY>" + ":"
+ "<CONSUMER_SECRET>").getBytes(), Base64.NO_WRAP);
tokenRequest.addHeader("Authorization", auth);
tokenRequest.addParam("grant_type", "client_credentials");
queue.add(tokenRequest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment