0

In Sandbox, the logged-in user needs to be a member of a group to register data products or apps.

How can I add my user to a group?

ra_tester
  • 252
  • 1
  • 7

1 Answers1

0

You, as user, are an identity of type Person. A Group is also a type of identity in Platform of Trust.

A Person must be linked to a Group with MemberOf type of link.

Using Identity API, you can create a Group type identity and connect your own user identity to the group with a MemberOf type link.

To create a group, run the following cURL command:

curl -i -X POST \
   -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9eyJzY29w...DVs5aaf" \
   -H "Content-Type: application/json" \
   -d \
"{
  "context": "https://standards.oftrust.net/v2/Context/Identity/Group/",
  "type": "Group",
  "data": {
    "name": "Company Oy"
  }
}" "https://api-sandbox.oftrust.net/identities/v1"

On Success, you'll get the following response including the ID of the created group.

Next, you need to link your user identity to the created group identity with a MemberOf type link.

option1: This post in StackOverflow discusses how to obtain the current logged-in user's ID.

OR,

option2: Start with getting your user ID (you need to be logged-in into the Sandbox) using /me end point of Login API

Request:

curl -i -X GET \
   -H "Authorization: Bearer eyJ0eXAi...hdEsJLNGV2YA" \
 "https://api-sandbox.oftrust.net/me"

Response:

HTTP/1.0 200

{
    "@context": "https://standards.oftrust.net/v2/Context/Identity/LegalParty/Person/",
    "@type": "Person",
    "@id": "33237067-14c3-4801-9e50-bf08406406e2",
    "email": "user@example.com",
    "role": "developer",
    "firstName": "Anna",
    "lastName": "Bar"
}

Then make a POST request to Identity API with Identity IDs of your user and the created group as parameters:

curl -i --request POST \
  --url https://api-sandbox.oftrust.net/identities/v1/{fromIdentityId}/link/{toIdentityId} \
  --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9eyJzY29w...DVs5aaf' \
  --header 'content-type: application/json' \
  --data '{
  "context": "https://standards.oftrust.net/v2/Context/Link/Role/MemberOf/",
  "type": "MemberOf"
}'

Remember to set the parameters as the following:

fromIdentityId = ID of your own user toIdentityID = ID of the created group above.

On success, you should receive the following response:

HTTP/1.0 201

{
  "@context": "https://standards.oftrust.net/v2/Context/Link/Role/MemberOf/",
  "@type": "MemberOf",
  "@id": "be7a2c57-03d8-46f4-aaf0-2b1ca118ef5c",
  "from": "8ac7494b-b7bc-4a63-a253-4b9b1887b262",
  "to": "a6b5a74e-bd98-4c9b-9561-932877258833",
  "data": {},
  "metadata": {
    "createdAt": "2019-09-12T09:49:24+00:00",
    "createdBy": "33237067-e72c-4f26-b78b-9f9e234b2e7d",
    "updatedAt": "2019-09-12T09:49:24+00:00",
    "updatedBy": "33237067-e72c-4f26-b78b-9f9e234b2e7d"
  }
}

Now you will bee able to use the created group to register data products and apps in Platform of Trust.

Alternatively, you can use world-sandbox.oftrust.net to create your group identity using the UI. Simply save the group ID that appears in the S-alert.

Checkout Identity API documentation here.

You can also use our Insomnia Workspace and Guide to execute chain request to create a Group.