API to create users?



  • Hi, is there a way to create users via api? Im not seeing any documentation.

    If wanting to use an external SSO system for single sign on, how do we create the users in jsreport for them to match with the external system? Do they need to be created by hand before the user is logging in? Or is there a way to auto-create users via api or on initial sign-on?


  • administrators

    hi!

    Hi, is there a way to create users via api?

    yes, any action you can do in the studio is possible to replicate with an HTTP API call (the studio uses that API to do its operations)

    Im not seeing any documentation.

    yes, unfortunately we don't have detailed docs (with examples for all possible actions) about the HTTP API, however we have just general docs about it here.

    a good way to check how to do something with HTTP API will be to inspect the requests of studio using the browser inspector.

    for example here is an screenshoot of the http request that studio does when creating an user, you can do the same request on your own to create user from your app.

    0_1565716672071_Captura de pantalla 2019-08-13 a la(s) 12.17.32 p. m..png

    you will find that you need a POST JSON request to http://jsreport-host/odata/users with body:

    {
      "username": "boris",
      "password": "xxxx"
    }
    

    and to enable other properties (Allow read all entities, Allow edit all entities) like the following, again you can do it in the studio and inspect the request to check how you can replicate it.

    0_1565716909727_Captura de pantalla 2019-08-13 a la(s) 12.21.30 p. m..png

    If wanting to use an external SSO system for single sign on, how do we create the users in jsreport for them to match with the external system?
    Do they need to be created by hand before the user is logging in? Or is there a way to auto-create users via api or on initial sign-on?

    you can send an http request to create the user in jsreport just when you are creating the user in your central system. jsreport only needs to have the user entity entity created, then the rest of calls to jsreport API can be authenticated and delegated to your authorization server as described here



  • Great, this should do it. Thanks!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.