Login (/login) Print

  • 2

Almost all of our API operations require authentication with a token and to get that token you must use this login operation.  The token is valid for 24 hours.

To get a token you may send a POST query to https://nacp01.noraina.net/api/login with a JSON payload like the one below:

{
    "mail": "{{user}}",
    "password": "{{pass}}"
}

If authentication succede you will get a JSON response similar to the one below:

{
  "auth": true,
  "token": "xxxxxxxxxxxxxxxxxxxx[...]",
  "status": "success",
  "data": {
    "message": "Login successful.",
    "token": "xxxxxxxxxxxxxxxxxxxx[...]"
  }
}

We try to follow JSend specification in all of our query operations but, in this case, there is some legacy. You should try to not use auth, and token properties in favor of status and data which are the correct JSend response properties.

As an example, here is how you can login to our plattform using curl:

curl --location --request POST 'https://nacp01.noraina.net/api/login' \
--header 'Content-Type: application/json' \
--data-raw '{
	"mail": "user",
	"password": "password"
}'

And the corresponding response would look like this:

{
  "auth": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
  "status": "success",
  "data": {
    "message": "Login successful.",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
  }
}

If the authentication fails, you will get an error response like the one that follows:

{
    "auth": false,
    "token": null,
    "status": "fail",
    "data": {
        "message": "Attempt to login by user failed.",
        "error": "Invalid user and/or password."
    }
}

Was this answer helpful?

« Back