private String generateToken(RealmModel realm) {
        ClientProvider clientProvider = session.getProvider(ClientProvider.class);
        ClientModel client = clientProvider.getClientByClientId(realm, options.getClientId());
        UserModel serviceAccount = session.getProvider(UserProvider.class).getServiceAccount(client);
        KeycloakContext ctx = session.getContext();

        long timestampNow = Time.currentTimeMillis();
        JsonWebToken token = new AccessToken()
             .id(KeycloakModelUtils.generateId())
             .type(TokenUtil.TOKEN_TYPE_BEARER)
             .subject(serviceAccount.getId())
             .issuedFor(client.getClientId())
             .audience(client.getName())
             .subject(serviceAccount.getId())
             .issuer(
                Urls.realmIssuer(
                    ctx.getUri().getBaseUri(),
                    ctx.getRealm().getName()
                )
             )
             .iat(timestampNow)
             .exp(timestampNow + Duration.ofMinutes(5).toMillis());
        // TODO(msavy): should we offer JWE? Might be nice for low-trust environments or plaintext tokenManager.encodeAndEncrypt
        return session.tokens().encode(token);
    }
Process a {@link org.keycloak.events.EventType#REGISTER} and send to Apiman Manager API via HTTP.
sso/keycloak/extensions/src/main/java/io/apiman/manager/sso/keycloak/event/processors/NewUserEventProcessor.java