Internal services communication
APIs that marked as internal alway start with /internal/ prefix and will not be exposed to public,
Access http://ppod.service.auth:3100/api/

Call internal API as SYSTEM (API begin with /internal/ prefix)
From Swagger ui, click Authorize button and enter into input
{"id": "__system", "user": "__system"}

Call other API to access as SYSTEM call, (SYSTEM call has full access to all data with no restriction)

Call internal API as specific user
- Call
POST /api/auth/loginwith the following request body:
{
"type": "password",
"clientId": "18kings-client-app-id",
"withPassword": {
"emailOrUsername": "sysadmin",
"password": "sysadmin"
}
}
Example response
{
"accessToken": "5f0971f38f1d859e83cbe8444cee159dc74ca5eb",
"accessTokenExpiresAt": "2023-06-24T19:51:06.528Z",
"refreshToken": "befde724910349e6be00aaa9fff65a26d088d76a",
"refreshTokenExpiresAt": "2023-07-08T18:51:06.528Z",
"scope": "read write",
"userId": "500768179843385796",
"clientId": "500767817378164404",
"idToken": "..."
}
- Call
POST /internal/auth/user-context?format=jsonwith the following request body:
{
"accessToken": "5f0971f38f1d859e83cbe8444cee159dc74ca5eb"
}
Example response
{
"id": "500768179843385796",
"clientId": "500767817378164404",
"authorization": {
"accessToken": "5f0971f38f1d859e83cbe8444cee159dc74ca5eb"
},
"user": {
"id": "500768179843385796",
"username": "sysadmin",
"firstName": "Sys",
"lastName": "Admin",
"locale": null,
"roles": ["sysadmin"],
"phoneNumber": null,
"avatar": null
}
}
- Stringify response data as user context
let userContext = JSON.stringify({
id: "500768179843385796",
clientId: "500767817378164404",
authorization: {
accessToken: "5f0971f38f1d859e83cbe8444cee159dc74ca5eb",
},
user: {
id: "500768179843385796",
username: "sysadmin",
firstName: "Sys",
lastName: "Admin",
roles: ["sysadmin"],
},
});
- Call any method with above userContext in header 'x-user-ctx'

Example response
{
"emailVerified": true,
"id": "500768179843385796",
"_guid": "user_3DpcYe3RoUt51HhENDKf7gtQ1M",
"createdAt": "2023-06-17T19:19:13.873Z",
"updatedAt": "2023-06-24T18:40:18.490Z",
"deletedAt": null,
"createdBy": "__system",
"updatedBy": "__system",
"deletedBy": null,
"firstName": "Sys",
"lastName": "Admin",
"username": "sysadmin",
"email": "bean.annt@gmail.com",
"locale": null,
"roles": ["sysadmin"],
"phoneNumber": null,
"avatar": null,
"birthday": null,
"gender": null,
"isActive": true,
"isGuest": false,
"isLocked": false,
"lockedAt": null
}