Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. @Override
  2. public byte[] getBody() throws AuthFailureError {
  3. String httpPostBody="grant_type=password&username=Alice&password=password123";
  4. // usually you'd have a field with some values you'd want to escape, you need to do it yourself if overriding getBody. here's how you do it
  5. try {
  6. httpPostBody=httpPostBody+"&randomFieldFilledWithAwkwardCharacters="+URLEncoder.encode("{{%stuffToBe Escaped/","UTF-8");
  7. } catch (UnsupportedEncodingException exception) {
  8. Log.e("ERROR", "exception", exception);
  9. // return null and don't pass any POST string if you encounter encoding error
  10. return null;
  11. }
  12. return httpPostBody.getBytes();
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement