Source:
public static UserSessionInfo signInWithSynapse(AuthenticationApi authApi, SignIn signIn) throws Exception { URI uri = URI.create(SYNAPSE_LOGIN_URL); String baseUrl = uri.getScheme()+"://"+uri.getHost()+"/"; OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) .addInterceptor(new ErrorResponseInterceptor()) .addInterceptor(new LoggingInterceptor()) .retryOnConnectionFailure(false).build(); Retrofit retrofit = new Retrofit.Builder().baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create()) .client(client).build(); RequestBody body = makeRequestBody(null, "username", signIn.getEmail(), "password", signIn.getPassword()); JsonObject object = retrofit.create(SynapseSignIn.class) .synapseSignIn(SYNAPSE_LOGIN_URL, body).execute().body(); String sessionToken = object.get("sessionToken").getAsString(); JsonObject idClaim = new JsonObject(); idClaim.addProperty("userId", (String)null); JsonObject claims = new JsonObject(); claims.add("id_token", idClaim); body = makeRequestBody(claims, "clientId", "100018", "scope", "openid", "responseType", "code", "redirectUri", OAUTH_CALLBACK_URL); Response<JsonObject> response = retrofit.create(OauthConsent.class) .oauthConsent(SYNAPSE_OAUTH_CONSENT, body, sessionToken).execute(); if (!response.isSuccessful()) { System.out.println(response.code()); System.out.println(response.message()); System.out.println(response.body().toString()); System.out.println(response.errorBody().toString()); } object = response.body(); String authToken = object.get("access_code").getAsString(); OAuthAuthorizationToken token = new OAuthAuthorizationToken() .appId(signIn.getAppId()) .authToken(authToken) .vendorId("synapse") .callbackUrl(OAUTH_CALLBACK_URL); return authApi.signInWithOauthToken(token).execute().body(); }

Target:
public static UserSessionInfo signInWithSynapse(AuthenticationApi authApi, SignIn signIn) throws Exception { URI uri = URI.create(SYNAPSE_LOGIN_URL); String baseUrl = uri.getScheme()+"://"+uri.getHost()+"/"; OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) .addInterceptor(new ErrorResponseInterceptor()) .addInterceptor(new LoggingInterceptor()) .retryOnConnectionFailure(false).build(); Retrofit retrofit = new Retrofit.Builder().baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create()) .client(client).build(); RequestBody body = makeRequestBody(null, "username", signIn.getEmail(), "password", signIn.getPassword()); JsonObject object = retrofit.create(SynapseSignIn.class) .synapseSignIn(SYNAPSE_LOGIN_URL, body).execute().body(); String sessionToken = object.get("sessionToken").getAsString(); JsonObject idClaim = new JsonObject(); idClaim.addProperty("userid", (String)null); JsonObject claims = new JsonObject(); claims.add("id_token", idClaim); body = makeRequestBody(claims, "clientId", "100018", "scope", "openid", "responseType", "code", "redirectUri", OAUTH_CALLBACK_URL); object = retrofit.create(OauthConsent.class) .oauthConsent(SYNAPSE_OAUTH_CONSENT, body, sessionToken).execute().body(); String authToken = object.get("access_code").getAsString(); OAuthAuthorizationToken token = new OAuthAuthorizationToken() .appId(signIn.getAppId()) .authToken(authToken) .vendorId("synapse") .callbackUrl(OAUTH_CALLBACK_URL); return authApi.signInWithOauthToken(token).execute().body(); }