JSONObject body = new JSONObject();
try {
body.put(ACCESS_TOKEN, token.getToken());
if (token instanceof ExpireToken) {
ExpireToken et = (ExpireToken) token;
body.put(EXPIRES_IN, et.getExpirePeriod());
body.put(REFRESH_TOKEN, et.getRefreshToken());
}
// TODO add scope
} catch (JSONException e) {
throw new ResourceException(Status.SERVER_ERROR_INTERNAL,
"Failed to generate JSON", e);