midnattssol
midnattssol4mo ago

I try to add a member to a granted project, but I keep getting an error "PROJECT-m9gKK"

I try to add a member to a granted project, but i keep getting this error: {"code":3,"message":"Errors.Project.Grant.Member.Invalid (PROJECT-m9gKK)","details":[{"@type":"type.googleapis.com/zitadel.v1.ErrorDetail","id":"PROJECT-m9gKK","message":"Errors.Project.Grant.Member.Invalid"}]} The user I try to add is existing and activated. I have double checked that I use the correct Project and Grant ID; and the correct Org ID is passed as a header to the POST request. I have as well checked that I don't pass any role to the request that is not valid or not existing. Any help is more than welcome. Ref to API call details: https://zitadel.com/docs/apis/resources/mgmt/management-service-add-project-grant-member
ZITADEL Docs
Members are users with permission to administrate ZITADEL on different levels. This request adds a new user to the members list on the project grant level with one or multiple roles.
6 Replies
Rajat Singh
Rajat Singh3mo ago
Hey @midnattssol thanks for your question, the user sending the request has which kind of roles in the org? Is it an "IAM_OWNER"?.
Elliot
Elliot3w ago
Hi Im having the same issue, my pat has those roles:
No description
Rajat
Rajat3w ago
hey @Elliot what version are you on? are you cloud or self hosted? what was the curl request that you are sending?. Thanks
Elliot
Elliot3w ago
im using the golang sdk, latest version, and self hosted
Rajat
Rajat3w ago
can you please share the code snippet or any errors logs.
Elliot
Elliot3w ago
failed to assign
project grant member role: rpc error: code = InvalidArgument desc =
Errors.Project.Grant.Member.Invalid (PROJECT-m9gKK)
failed to assign
project grant member role: rpc error: code = InvalidArgument desc =
Errors.Project.Grant.Member.Invalid (PROJECT-m9gKK)
var projectRoles []string
switch role {
case "ADMIN":
projectRoles = append(projectRoles, "ADMIN")
case "USER":
projectRoles = append(projectRoles, "USER")
default:
return fmt.Errorf("unknown role: %s", role)
}

orgCtx := middleware.SetOrgID(ctx, orgID)

req := &management.AddProjectGrantMemberRequest{
ProjectId: projectID,
GrantId: grantID,
UserId: userID,
Roles: projectRoles,
}

_, err := zitadelClient.GetClient().ManagementService().AddProjectGrantMember(orgCtx, req)
var projectRoles []string
switch role {
case "ADMIN":
projectRoles = append(projectRoles, "ADMIN")
case "USER":
projectRoles = append(projectRoles, "USER")
default:
return fmt.Errorf("unknown role: %s", role)
}

orgCtx := middleware.SetOrgID(ctx, orgID)

req := &management.AddProjectGrantMemberRequest{
ProjectId: projectID,
GrantId: grantID,
UserId: userID,
Roles: projectRoles,
}

_, err := zitadelClient.GetClient().ManagementService().AddProjectGrantMember(orgCtx, req)
just in case, my users are not active (pending), and i have correctly granted the project to the organization

Did you find this page helpful?