API authentication via user login
Login as user 'bpcadmin'
Call via CURL
curl -X POST \
-c cookies.txt \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
"http://localhost:8181/cxf/bpc-core/authentication" \
--data-urlencode "tenantname=DEFAULT" \
--data-urlencode "username=bpcadmin" \
--data-urlencode "password=bpcadmin"
Response
{
"loginName": "bpcadmin",
"email": "",
"firstName": "",
"lastName": "",
"organisations": [ "DEFAULT" ],
"inactiveOrganisations": [],
"roles": [ "bpcadmin", "bpcuser" ],
"rights": [ "loadModule_dashboard", "loadModule_account", "loadModule_blank" ],
"principals": {
"X-Csrf-Token": [ "_4rpjBU5_dEFBVVAVkF6LUKV1AjvdRWJSC0QLrOoZtagdFfILQoOgtGhu4X8ppd2X2kbowjl8UEp1j_tKEPaIw1c2FbcQNJfaAX-AgoiI8Cse9_FHPO9omcm8z-UE3F-_ScFZfqIL9ZRPAWWpfkM48G20OU3nu8_E5sPdIqF8EY" ],
"org.apache.karaf.jaas.boot.principal.UserPrincipal": [ "bpcadmin" ]
},
"customData": {},
"expirationDate": 1648067566204
}
You must save the cookies and keep the X-Csrf-Token from the JSON response. It will be used in the next step.
Check whether the session is valid
Call via CURL
curl -X GET \
-b cookies.txt \
"http://localhost:8181/cxf/bpc-core/authentication"
Response if successful
{
"loginName": "bpcadmin",
"email": "",
"firstName": "",
"lastName": "",
"organisations": [ "DEFAULT" ],
"inactiveOrganisations": [],
"roles": [ "bpcadmin", "bpcuser" ],
"rights": [ "loadModule_dashboard", "loadModule_account", "loadModule_blank" ],
"principals": {
"X-Csrf-Token": [ "_4rpjBU5_dEFBVVAVkF6LUKV1AjvdRWJSC0QLrOoZtagdFfILQoOgtGhu4X8ppd2X2kbowjl8UEp1j_tKEPaIw1c2FbcQNJfaAX-AgoiI8Cse9_FHPO9omcm8z-UE3F-_ScFZfqIL9ZRPAWWpfkM48G20OU3nu8_E5sPdIqF8EY" ],
"org.apache.karaf.jaas.boot.principal.UserPrincipal": [ "bpcadmin" ]
},
"customData": {},
"expirationDate": 1648067566204
}
Response if an error occurred
{
"error": {
"messageKey": "CORE_ERROR_IDENTITY_PROVIDER_AUTHENTICATION_FAILED",
"code": 540,
"name": "AUTHENTICATION_UNAUTHORIZED",
"message": "Authentication failed",
"properties": {}
}
}
Call API endpoint
Set the cookies and the X-Csrf-Token.
curl -X GET \
-b cookies.txt \
-H 'X-Csrf-Token: _4rpjBU5_dEFBVVAVkF6LUKV1AjvdRWJSC0QLrOoZtagdFfILQoOgtGhu4X8ppd2X2kbowjl8UEp1j_tKEPaIw1c2FbcQNJfaAX-AgoiI8Cse9_FHPO9omcm8z-UE3F-_ScFZfqIL9ZRPAWWpfkM48G20OU3nu8_E5sPdIqF8EY' \
-H 'Content-Type: application/json' \
"http://localhost:8181/cxf/bpc-core/opensearch/indices"
|
The |
Keywords: