Replies: 2 comments 1 reply
-
|
I'll add that I can't get the V1 API to work - if I call |
Beta Was this translation helpful? Give feedback.
-
|
In ZITADEL, the “Actions / Flows” you configured (External Authentication → Post creation) are tied to interactive authentication/registration flows. If you create users directly via the API endpoint So for users created via the API, the supported/reliable solution is: Create the user Then explicitly add a user grant (project role) via the Management API. You want a “user grant” (application role membership), not a “project member” or “project grant member”: Project Member / Project Grant Member = administrators who can manage ZITADEL (management roles) User Grant = the user’s application roles for a project (what you want for default access) Example flow:
curl -X POST "https://<YOUR_DOMAIN>/v2/users/human" This returns the new user’s id.
curl -X POST "https://<YOUR_DOMAIN>/management/v1/users/<USER_ID>/grants" This is the API that assigns application roles to a user for a project (“user grant”). It is the direct equivalent of what your v1 Action was doing with If you get 403 with your service user token, that means the service user does not have the required ZITADEL management permissions to create user grants (being able to create users is not the same as being allowed to assign project roles). Ensure the service user is authorized to access ZITADEL APIs and has the necessary management permissions for the organization/project. https://zitadel.com/docs/guides/integrate/zitadel-apis/access-zitadel-apis Summary Actions/Flows are for auth/registration events, not guaranteed for API-driven user provisioning. For API-created users, assign the default application role by calling “Add User Grant” right after creation. Use “User Grant” for app roles; do not use “Project Member / Project Grant Member” unless you are assigning ZITADEL admin/manager roles. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So I'm creating new users via the API using a service user token and the
v2/users/humanendpoint. This works fine.What I can't figure out is how to then add a role to the newly created user without doing it manually in the dashboard.
I'd like to be able to do this either by:
I created this script in the Actions section:
and created a Flow with
External Authentication->Post CreationIt does not run when I create a new user though.
Add Project Memberdiffer fromAdd Project Grant MemberfromAdd User Grant?Beta Was this translation helpful? Give feedback.
All reactions