From 43c9c92c534e0c4a76959f68c68d3dd4146e0f1d Mon Sep 17 00:00:00 2001 From: rotembr Date: Tue, 13 Mar 2018 12:22:01 +0200 Subject: [PATCH] Development (#76) App API for AppIDRequest with body and tokens --- .../internal/network/AppIDRequest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/src/main/java/com/ibm/bluemix/appid/android/internal/network/AppIDRequest.java b/lib/src/main/java/com/ibm/bluemix/appid/android/internal/network/AppIDRequest.java index 2f67992..7621965 100644 --- a/lib/src/main/java/com/ibm/bluemix/appid/android/internal/network/AppIDRequest.java +++ b/lib/src/main/java/com/ibm/bluemix/appid/android/internal/network/AppIDRequest.java @@ -105,11 +105,33 @@ public void send(final ResponseListener listener, final RequestBody requestBody, } } + public void send(final ResponseListener listener, final RequestBody requestBody, final AccessToken accessToken, final IdentityToken identityToken) { + + if (accessToken != null && identityToken != null) { + removeHeaders("Authorization"); + addHeader("Authorization", "Bearer " + accessToken.getRaw() + " " + identityToken.getRaw()); + } + + if (requestBody != null) { + super.sendRequest(null, listener, requestBody); + } else { + send(listener); + } + } + @Override public void send (JSONObject json, ResponseListener listener) { super.send(json, listener); } + public void send (JSONObject json, ResponseListener listener, final AccessToken accessToken, final IdentityToken identityToken) { + if (accessToken != null && identityToken != null) { + removeHeaders("Authorization"); + addHeader("Authorization", "Bearer " + accessToken.getRaw() + " " + identityToken.getRaw()); + } + super.send(json, listener); + } + @Override public void send (Map formParameters, ResponseListener listener) { super.send(formParameters, listener);