Grok API to create users

Hi Datagrok team,

Quick question: Is it possible to create Grok users via Script from local machine? This would speed our local environment setup a lot.
I am thinking about something similar to the way we are able to configure credentials through a script from our local machines?

You can use signup REST API POST /api/users/signup

{"type":"signup","login":"login","email":"email","password":"cGFzc3dvcmQ="}

password is base64 encoded password.
It returns a JSON with token, you can use for further requests.
Perform GET /api/users/current with Authorization header set to this token to get user information.

This is helpful thanks. Just another question: Is there a way we can create a user object through the Grok API as the user would be created through our internal auth integration?

Reason for asking: We would like to manual create users (which are missing in Grok context) once they are selected for an internal project. In that case we won’t have to ask the user to manually open Grok once to ensure the user is created?

The core supports pre-created users to share entities with.
Later the real user can login with this account (if email or login matches), and see all of shared instances.
There is an option to include these accounts to a group too.

I will check if it’s possible to achieve this with js-api, and if it works, I’ll make an example.
Anyway, there is a function to create deactivated accounts, and we will expose it to js-api.

1 Like

Hey @alex.paramonov your suggestions sounds good. We would love to have a way to create users in through the API. Any updates on the JS-API exposure or example how to use?

Hey @alex.paramonov quick ping from my side again. Is there any update on this? :wink:

Hey, @andreas.gasser.novartis.com,
Since 0.104.0 version you can use:

let user = DG.User.create();
user.login = 'login';
user.email = 'email';
await grok.dapi.users.save(user); 

This code creates and saves the user. Right now you can’t set a password, but the user can reset it, or use oauth login method.

2 Likes

This is pretty convenient! Just want to double-check though - when a user is created this way, it can be added to groups and assigned other privileges, so once a user logins for the first time everything would already be set up?

Also, I think it would make sense to create a UI (that can reside in a plugin) for batch user creation

Yes, it’s a fully-functional user. I’m also working on status control, so you can create a pre-signed up user, who can sign-up and have all the things in place, or you can create a user with a password set up.

UI for bulk creation is a great idea. Let’s make it as a part of PowerPack :slight_smile:

1 Like