JSONObject toRtn = new JSONObject();
if (record != null) {
try {
StableUserId userId = record.getUserId();
ParticipantId participantId = record.getParticipantId();
OAuthCredentials oAuthCredentials = record.getOAuthCredentials();
userContext.setUserId(userId);
userContext.setParticipantId(participantId);
userContext.setOAuthCredentials(oAuthCredentials);
toRtn.put(TokenBasedAccountLookup.USER_ID_KEY, userId.getId());
toRtn.put("participantId", participantId.getAddress());
toRtn.put("access_token", xsrfHelper.get().createToken(oAuthCredentials.getAccessToken()));
} catch (JSONException e) {
throw new RuntimeException("Bad JSON: " + toRtn, e);
}
}
resp.setStatus(200);