Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding users programmatically #110

Closed
carlosc-metacampus opened this issue Oct 19, 2022 · 1 comment
Closed

Adding users programmatically #110

carlosc-metacampus opened this issue Oct 19, 2022 · 1 comment
Labels
question Further information is requested

Comments

@carlosc-metacampus
Copy link

Good evening,

I've recently set up an on-premises taiga instance for a client.

I don't want to enable public registration as it should be kept to organization users only, ideally set up so AWS lambdas ran when new IAM users are created/disabled may create/delete the taiga user.

I've tried the private POST auth/register API (as specified in https://docs.taiga.io/api.html#auth-private-registry), however it asks for a token parameter I can't seem to get. Docs suggest it comes from an invitation, which I attempt to create from the POST membership API (https://docs.taiga.io/api.html#memberships-create). However this doesn't give me back any kind of token.

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${AUTH_TOKEN}" \
-d '{
        "project": 1,
        "role": 3,
        "username": "test@test.com"
    }' \
-s http://localhost:8000/api/v1/memberships
{
	"id": 93,
	"user": null,
	"project": 1,
	"role": 3,
	"is_admin": false,
	"created_at": "2022-10-19T16:21:12.382Z",
	"invited_by": {
		"username": "xxxxxxxx",
		"full_name_display": "xxxxxxxx",
		"photo": null,
		"big_photo": null,
		"gravatar_id": "a7350cd9a284f500f3bf1512daef071e",
		"is_active": true,
		"id": 23
	},
	"invitation_extra_text": null,
	"user_order": 1666196472382,
	"role_name": "Front",
	"full_name": null,
	"is_user_active": false,
	"color": null,
	"photo": null,
	"gravatar_id": null,
	"project_name": "Project Example 1",
	"project_slug": "project-1",
	"is_owner": null,
	"email": "test@test.com",
	"user_email": null
}

I've seen other issues mentioning being able to create users through python, but this will involve having to ssh into taiga's host, which I'd like to avoid.

Is there some kind of API (like the /admin/users/user/add API, that I can't use programmatically because of the CSRF token), that may be used for this, or alternatively, would you be so kind to provide some guidance as to how to achieve this with the advertised APIs?

Thanks

@carlosc-metacampus carlosc-metacampus added the question Further information is requested label Oct 19, 2022
@Xaviju Xaviju changed the title [Q] Adding users programmatically Adding users programmatically Oct 28, 2022
@Xaviju
Copy link
Member

Xaviju commented Oct 28, 2022

Hi @carlosc-metacampus
The token you are looking for is part of the email that is sent to the user when it is invited to a project using the endpoint you suggested (https://docs.taiga.io/api.html#memberships-create). In the email, there should be a URL to accept the invitation with the token. You can copy it from there.
This token is only available in the email or the database, not exposed in the API.

@Xaviju Xaviju closed this as completed Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants