I have an authentication call that i\'m trying to make using Retrofit on Android. The call returns a 302 to either a success or failure page. The original 302 response brings ba
to prevent the redirect you have to configure your client, e.g with OkHttp 2:
private sendRequest() {
OkHttpClient client = new OkHttpClient();
client.setFollowRedirects(false);
connectAdapter = new RestAdapter.Builder()
.setClient(new OkClient(client))
.setEndpoint("http://yourendpoint")
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
connectAdapter.create(YourRequest.class).sendMyRequest("login","password");
}
With OKHTTP 3 (you can read this answer from @gropapa):
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.followRedirects(false);
OkHttpClient httpClient = builder.build();