Last active
December 18, 2015 14:19
-
-
Save smaspe/5796296 to your computer and use it in GitHub Desktop.
This file contains 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
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