π Login
This endpoint accepts only one body.
Description
ENDPOINT | DESCRIPTION | METHOD | EXEMPLE |
---|---|---|---|
/_login/{strategy}?expiresIn={expiresIn} | Authentication with username and password | POST | https://api.comexposium-sso.com/_login/local?expiresIn=12h |
Strategy: The login strategy is always "local"
ExpiresIn: Set the expiration duration. If a raw number is provided (not enclosed between quotes), then the expiration delay is in milliseconds. If this value is a string, then its content is parsed by the ms library
Body
{
"username": "[email protected]",
"password": "myPassword"
}
Call Exemple
curl -X POST "https://api.comexposium-sso.com/_login/local?expiresIn=12h" -H "accept: application/json" -H "content-type: application/json" -d "{ \"username\": \"[email protected]\", \"password\": \"myPassword\"}"
Details
Responses
You can get a 200 or a 403 code response by using this endpoint.
Success
_id: internal user ID, jwt: JWT Token of the user
Exemple:
{
"requestId": "dcd5e356-042f-40ce-96f2-bda2580e9b72",
"status": 200,
"error": null,
"controller": "auth",
"action": "login",
"collection": null,
"index": null,
"volatile": null,
"result": {
"_id": "57f1d1ae-fbea-4a7c-aeac-3a1abac76a03",
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1N2YxZDFhZS1mYmVhLTRhN2MtYWVhYy0zYTFhYmFjNzZhMDMiLCJpYXQiOjE1NzQzNTA2NDcsImV4cCI6MTU3NDM5Mzg0N30.cga2mJm2NdwGnZ27wifnBAb3tgHxO--M4zD7S3rQXpY",
"expiresAt": 1574393847798,
"ttl": 43200000
}
}
Errors
Login failed
Exemple:
{
"requestId": "ea426e47-fd23-4f95-8ccb-cf0a196af542",
"status": 401,
"error": {
"message": "wrong username or password",
"status": 401,
"stack": "UnauthorizedError: wrong username or password\n at UnauthorizedError (/opt/kuzzle/node_modules/kuzzle-common-objects/lib/errors/unauthorizedError.js:5:5)\n at authCB (/opt/kuzzle/lib/api/core/auth/passportWrapper.js:71:25)\n at allFailed (/opt/kuzzle/node_modules/passport/lib/middleware/authenticate.js:107:18)\n at attempt (/opt/kuzzle/node_modules/passport/lib/middleware/authenticate.js:180:28)\n at Strategy.strategy.fail (/opt/kuzzle/node_modules/passport/lib/middleware/authenticate.js:297:9)\n at verified (/opt/kuzzle/plugins/available/kuzzle-plugin-auth-passport-local/node_modules/passport-local/lib/strategy.js:82:30)\n at ret.then.then.result (/opt/kuzzle/lib/api/core/plugins/pluginsManager.js:514:13)\n at tryCatcher (/opt/kuzzle/node_modules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFromHandler (/opt/kuzzle/node_modules/bluebird/js/release/promise.js:512:31)\n at Promise._settlePromise (/opt/kuzzle/node_modules/bluebird/js/release/promise.js:569:18)\n at Promise._settlePromise0 (/opt/kuzzle/node_modules/bluebird/js/release/promise.js:614:10)\n at Promise._settlePromises (/opt/kuzzle/node_modules/bluebird/js/release/promise.js:693:18)\n at Async._drainQueue (/opt/kuzzle/node_modules/bluebird/js/release/async.js:133:16)\n at Async._drainQueues (/opt/kuzzle/node_modules/bluebird/js/release/async.js:143:10)\n at Immediate.Async.drainQueues (/opt/kuzzle/node_modules/bluebird/js/release/async.js:17:14)\n at runCallback (timers.js:637:20)\n at tryOnImmediate (timers.js:610:5)\n at processImmediate [as _immediateCallback] (timers.js:582:5)"
},
"controller": "auth",
"action": "login",
"collection": null,
"index": null,
"volatile": null,
"result": null
}
β π Presentation π€¦ββ Logout β