Hi,
I am trying to use a service user on my backend to generate new groups when a user signs up and decides to input information about their company. I am doing so as I am then using the name of this group to restrict access to data via a restricted view.
One issue I am having is that the create group endpoint doesn’t seem to work for my user.
My auth client is:
const auth = createConfidentialOauthClient(clientId, clientSecret, url, ['api:ontologies-read', 'api:ontologies-write', 'api:admin-read', 'api:admin-write']);
const client = createClient(url, ontologyRid, auth);
Then my request is:
const companyId = `company-${Math.random().toString(36)}`;
const serviceUserToken = auth.getTokenOrUndefined();
const groupResponse = await fetch(`https://${HOSTNAME}/api/v2/admin/groups`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${serviceUserToken}`,
},
body: JSON.stringify({
name: companyId,
organizations: ['[org_id]'],
description: `Auto-generated group for company ${companyId}`
})
});
Note that simply getting the list of groups does work.
On the organization settings page for the organization I want to add the group to, I have the following and have added the service user. I am not sure where to proceed in debugging from here!