Android - Retrofit 2 - Authenticator Result
<p>I'm trying to use Retrofit (2.0.0-beta3), but when using an Authenticator to add a token, I can't seem to get the data from the synchronous call. Our logging on the back-end just shows a lot of login attempts, but I can't get the data from the body to actually add to the header.</p>

<pre><code>    public static class TokenAuthenticator implements Authenticator {
    @Override
    public Request authenticate(Route route, Response response) throws IOException {
        // Refresh your access_token using a synchronous api request
        UserService userService = createService(UserService.class);

        Call&lt;Session&gt; call = userService.emailLogin(new Credentials("handle", "pass"));

        // This call is made correctly, as it shows up on the back-end.
        Session body = call.execute().body();

        // This line is never hit.
        Logger.d("Session token: " + body.token);

        // Add new header to rejected request and retry it
        return response.request().newBuilder()
                .header("Auth-Token", body.token)
                .build();
        }
    }
</code></pre>

<p>I'm not exactly too sure on why it's not even printing anything out. Any tips on how to solve this issue would be greatly appreciated, thanks for taking the time to help.</p>

<hr>

<p>These are the sources I've been reading on how to implement Retrofit.</p>

<p>Using Authenticator:</p>

<ul>
<li><p><a href="https://stackoverflow.com/a/31624433/3106174">https://stackoverflow.com/a/31624433/3106174</a></p></li>
<li><p><a href="https://github.com/square/okhttp/wiki/Recipes#handling-authentication" rel="nofollow noreferrer">https://github.com/square/okhttp/wiki/Recipes#handling-authentication</a></p></li>
</ul>

<p>Making synchronous calls with Retrofit 2:</p>

<ul>
<li><a href="https://futurestud.io/blog/retrofit-synchronous-and-asynchronous-requests" rel="nofollow noreferrer">https://futurestud.io/blog/retrofit-synchronous-and-asynchronous-requests</a></li>
</ul>