MOSIP 1.2.0 API endpoints tutorials

Aside from the MOSIP 1.2.0 API documentation on the web, are there any tutorials on API endpoints on how to use them e.g. what are the steps; what are the commands; what are the values that need to be put in the commands.

For Example
https://dev2.mosip.net/idrepository/v1/identity/idvid/{id}
What value should be placed in {id}

https://dev2.mosip.net/idrepository/v1/identity/authtypes/status/{ID}
What value should be placed in {ID}

Is there a document or a tutorial that will explain these commands, and what are the values needed for these commands for MOSIP 1.2.0 API endpoints?

Something similar to this but for MOSIP 1.2.0 and all the API endpoints
https://docs.mosip.io/1.1.5/apis/id-repository-apis

Hi @rcsampang

For our new development on MOSIP, we have started using Stoplight for API documentation.

Currently, we have a few modules documented here: https://mosip.stoplight.io/

If you are looking at any specific API documentation, please let me know; we will add it to Stoplight for the time being.

Thanks and Regards,
Rounak

1 Like

Hello @nayakrounak

This is quite useful for a proficient API developer. But I am not yet that competent in API development, thus I am still having difficulty in understanding them.

I was hoping to find a tutorial on other commands we could use to check if our MOSIP sandbox API endpoints are working as expected similar to the one discussed previously in my earlier post.

In my previous post I asked how to find the person’s UIN

The steps given were:

  1. Please check below roles are assigned to ‘mosip-regproc-client’ service account from Keycloaks:
    Publish_Registration_Processor_workFlow_Paused_for_Additional_Info_Event_General
    Subscriber_Registration_Processor_workFlow_Paused_for_Additional_Info_Event_General.

If not, please add these roles and restart ‘regproc-notifier and regproc-workflow’ stages.

  1. Get details from ID Repo - run the command below -
    https://api-internal.yourenv.mosip.net/idrepository/v1/identity/idvid/yourRID?type=bio
    Please replace the host name and RID details as per your environment.

  2. Before trying ID Repo, please do authentication
    https://api-internal.qatriple.mosip.net/v1/authmanager/swagger-ui/index.html?configUrl=/v1/authmanager/v3/api-docs/swagger-config#/authmanager/clientIdSecretKey

You can get the clientIdSecretKey by running the command in MOSIP K8s cluster
$ echo “PMS Client Password : $( kubectl -n keycloak get secrets keycloak-client-secrets -o jsonpath={.data.mosip_regproc_client_secret} | base64 -d )”

So basically what I am looking for are other steps/commands that can be used to check the person’s registration information by leveraging the use of MOSIP API endpoints.

For example, there is this command in MOSIP 1.2.0 API documentation
(Id Repository Identity Service)

https://dev2.mosip.net/idrepository/v1/identity/authtypes/status/{ID}

What is its’ function ? Check status of the person’s registration?
What should be put in place of {ID} ? I tried RID and UIN but I got an unauthorized error prompt
Do I have to authenticate first before I run this command? How? What information are needed for the authentication?

I am trying to learn by issuing the get commands in the MOSIP API documentation ( https://mosip.github.io/documentation/1.2.0/1.2.0.html) but I don’t know where to find more information for each command, what steps to take, commands to run, and values to use.

Is there an existing tutorial for that?

Hi @rcsampang ,

We don’t have a proper tutorial as of now. But I will be happy to explain a couple of the APIs here.

API Type 1

If you are looking to check the status of the resident’s packet, then you can use the below resident-service API.

Swagger for Resident Services: (https://{baseURL}/resident/v1/swagger-ui/index.html?configUrl=/resident/v1/v3/api-docs/swagger-config#/resident-controller/getRidStatus))

This API doesn’t need any authentication :slight_smile:

Request URL: https://{baseURL}/resident/v1/rid/check-status

Request Body:

{
  "id": "mosip.resident.checkstatus",
  "version": "v1",
  "requesttime": "2023-06-16T11:45:08.162Z",
  "request": {
    "individualId": "11880117741004320230321171036",
    "individualIdType": "RID"
  }
}

Response Body:

{
  "id": "mosip.resident.checkstatus",
  "version": "v1",
  "responsetime": "2023-06-16T11:46:38.556Z",
  "metadata": null,
  "response": {
    "ridStatus": "PROCESSED"
  },
  "errors": null
}

API Type 2

Now there is another API in the Registration Processor to get the status of the resident’s packet.

Swagger for Registration Processor: (https://{baseURL}/registrationprocessor/v1/registrationstatus/swagger-ui/index.html?configUrl=/registrationprocessor/v1/registrationstatus/v3/api-docs/swagger-config))

This API needs authentication. Hence, you need to get an authentication token with one of the roles specified in registration-processor-default.properties.

mosip.role.registration.getPostexternalstatussearch=REGISTRATION_ADMIN,REGISTRATION_OFFICER,REGISTRATION_SUPERVISOR,RESIDENT

Here the roles supported by the API are REGISTRATION_ADMIN, REGISTRATION_OFFICER, REGISTRATION_SUPERVISOR, or RESIDENT.

For generating the authentication token with the required role, you need to use the auth manager APIs.

Swagger for Auth Manager: (https://{baseURL}/v1/authmanager/swagger-ui/index.html?configUrl=/v1/authmanager/v3/api-docs/swagger-config#/authmanager/clientIdSecretKey)

For getting this token, you need to authenticate using the client credentials, which is having the role RESIDENT, which you can find in keycloak.

Request URL: https://{baseURL}/v1/authmanager/authenticate/clientidsecretkey

Request Body:

{
  "id": "string",
  "version": "string",
  "requesttime": "2023-06-16T11:44:29.563Z",
  "metadata": {},
  "request": {
    "clientId": "mosip-resident-client",
    "secretKey": "<secret from keycloak>",
    "appId": "resident"
  }
}

Response Body:

{
  "id": "string",
  "version": "string",
  "responsetime": "2023-06-16T12:48:32.532Z",
  "metadata": null,
  "response": {
    "status": "Success",
    "message": "Clientid and Token combination had been validated successfully"
  },
  "errors": null
}

Here, in the response header, you will have the authentication token below,

 access-control-allow-credentials: true 
 access-control-allow-headers: Date,Content-Type,Accept,X-Requested-With,Authorization,From,X-Auth-Token,Request-Id 
 access-control-allow-methods: POST,GET,OPTIONS,DELETE,PUT,PATCH 
 access-control-allow-origin: https://api-internal.collab.mosip.net 
 access-control-expose-headers: Set-Cookie 
 authorization: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI2SkdrUVZUZTVCcXZFeVZRemszUm8xT0hRSkdzZ0x6QVVSaS1za3A1UUMwIn0.eyJleHAiOjE2ODY5NTU3MTIsImlhdCI6MTY4NjkxOTcxMiwianRpIjoiMDI3MDJmODItNWRjNC00MTMyLWEyNGMtMjc5NTIzOGVlZTViIiwiaXNzIjoiaHR0cHM6Ly9pYW0uY29sbGFiLm1vc2lwLm5ldC9hdXRoL3JlYWxtcy9tb3NpcCIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiIwZmUxMmIzYS05NzBjLTQ0NjgtYWQxZS1kOWY4ZmU0NmVkYzAiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJtb3NpcC1yZXNpZGVudC1jbGllbnQiLCJhY3IiOiIxIiwicmVhbG1fYWNjZXNz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_AT3Bm5TVu-2s5jmfNqjqtlgOdxzF1KfGdrEQKeFeNig9y7ta6Kkg2uZ8qd5QeAaUjCeTp93lgqxMnRIOWSEMqPSzB6cEf6GsqhHJod_MPTcuY1vt8a1_QVptSNge-yvVlt6ATd27873w 
 cache-control: no-cache,no-store,max-age=0,must-revalidate 
 connection: keep-alive 
 content-length: 213 
 content-type: application/json;charset=UTF-8 
 date: Fri,16 Jun 2023 12:48:32 GMT 
 expires: 0 
 pragma: no-cache 
 server: nginx/1.18.0 (Ubuntu) 
 x-content-type-options: nosniff 
 x-envoy-upstream-service-time: 79 
 x-frame-options: SAMEORIGIN 
 x-xss-protection: 1; mode=block 

Now, when you use the Registration Processor API, you need to add the above token to the cookie.

Request URL: https://{baseURL}/registrationprocessor/v1/registrationstatus/packetexternalstatus

Request Body:

{
  "id": "mosip.registration.packet.external.status",
  "version": "1.0",
  "requesttime": "2023-06-16T12:59:50.079Z",
  "request": [
    {
      "packetId": "10001101070000520221112023125"
    }
  ]
}

Response Body:

{
  "response": [
    {
      "packetId": "10001101070000520221112023125",
      "statusCode": "ACCEPTED"
    }
  ],
  "errors": [],
  "id": "mosip.registration.packet.external.status",
  "version": "1.0",
  "responsetime": "2023-06-16T13:07:48.905Z"
}

Hope this will help you. Let me know if you need anything else…

2 Likes

Please find the curl command to add the authentication token in the cookie

curl --location 'https://qa3.mosip.net/v1/policymanager/policies/group/new' \
--header 'Content-Type: application/json' \
--header 'Cookie: Authorization=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJQbHBYczdJWG9pY0hTeldPeWVQTjdXZFl4WmhsclczQV9RbXFjUlRRaEJRIn0.eyJqdGkiOiJlYjllMjgzNi1hNmQzLTQyMjAtOTc2MS1mNzRmZTQ5NDgxNTQiLCJleHAiOjE2ODU2MzM2NDIsIm5iZiI6MCwiaWF0IjoxNjg1NTk3NjQyLCJpc3MiOiJodHRwczovL3FhMy5tb3NpcC5uZXQva2V5Y2xvYWsvYX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p-policygroup182"
  },
  "requesttime": "2023-06-16T13:36:18.495Z",
  "version": "LTS"
}
'
1 Like

Thank you very much @nayakrounak This is quite helpful.

I will study them further and ask more questions later.

Best regards!

@anyone

Quick question, what value should be put in {ID} in this command?

https://dev2.mosip.net/idrepository/v1/identity/authtypes/status/{ID}

The value for ID here is UIN or VID.

This Get API is used to get all the Authentication Types and their respective Statuses for the individual.

Hi @nayakrounak I tried placing UIN in the command. I ended up with unauthorized error.

I tried authenticating using the command in my previous post

https://api-internal.qatriple.mosip.net/v1/authmanager/swagger-ui/index.html?configUrl=/v1/authmanager/v3/api-docs/swagger-config#/authmanager/clientIdSecretKey

I still ended up with the same unauthorized error.

What is the right way to authenticate?

Hi @rcsampang ,

As you can see, this is an ID REPOSITORY API - The role details to access this API will be available in id-repository-default.properties in the configurations, as shown below:

Now you need to use client credentials that have one of the roles specified against the API configuration; here the roles are RESIDENT or ID_REPOSITORY.

Make sure you are using a credential that has one of the above roles, or add one of the roles to the client that you are using.

Thanks,
Rounak