diff --git a/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/OkHttpHeaderInterceptor.java b/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/OkHttpHeaderInterceptor.java index 3e285f6e19..16b8b734ef 100644 --- a/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/OkHttpHeaderInterceptor.java +++ b/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/OkHttpHeaderInterceptor.java @@ -1,18 +1,15 @@ package org.wordpress.mobile.WPAndroidGlue; -import android.text.TextUtils; - import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnAuthHeaderRequestedListener; import java.io.IOException; +import java.util.Map; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; public class OkHttpHeaderInterceptor implements Interceptor { - private static final String AUTHORIZATION_HEADER_KEY = "Authorization"; - private OnAuthHeaderRequestedListener mOnAuthHeaderRequestedListener; void setOnAuthHeaderRequestedListener(OnAuthHeaderRequestedListener onAuthHeaderRequestedListener) { @@ -23,10 +20,13 @@ void setOnAuthHeaderRequestedListener(OnAuthHeaderRequestedListener onAuthHeader public Response intercept(Chain chain) throws IOException { Request.Builder builder = chain.request().newBuilder(); - String authHeader = mOnAuthHeaderRequestedListener != null + Map authHeaders = mOnAuthHeaderRequestedListener != null ? mOnAuthHeaderRequestedListener.onAuthHeaderRequested(chain.request().url().toString()) : null; - if (!TextUtils.isEmpty(authHeader)) { - builder.addHeader(AUTHORIZATION_HEADER_KEY, authHeader); + + if (authHeaders != null) { + for (Map.Entry entry : authHeaders.entrySet()) { + builder.addHeader(entry.getKey(), entry.getValue()); + } } return chain.proceed(builder.build()); diff --git a/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java b/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java index 32d76330e5..1996768057 100644 --- a/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java +++ b/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java @@ -147,7 +147,7 @@ public interface OnEditorMountListener { } public interface OnAuthHeaderRequestedListener { - String onAuthHeaderRequested(String url); + Map onAuthHeaderRequested(String url); } public interface OnEditorAutosaveListener {