if (!application.registrationAllowed)
return Response.status(Response.Status.FORBIDDEN).build();
try {
final Guest guest = guestService.createGuest(username, firstname, lastname, null, email, Guest.RegistrationMethod.REGISTRATION_METHOD_API, application.uid);
final AuthorizationToken authorizationToken = oAuth2MgmtService.issueAuthorizationToken(guest.getId(), application.getId());
TechnicalAuthorizationTokenModel authorizationTokenModel = new TechnicalAuthorizationTokenModel(authorizationToken, guest);
final String json = (new ObjectMapper()).writeValueAsString(authorizationTokenModel);
return Response.ok(json).build();
} catch (UsernameAlreadyTakenException e) {
return Response.status(Response.Status.BAD_REQUEST).entity("This username is already taken").build();
} catch (ExistingEmailException e) {