Table of Contents

Back to Users / JESS / JEA / JBODY API

Confirm User Credential


The user's credential to be sent to the ENSIMS Web Service include the registered email address and the password, along with the existing session token to confirm the current session.

Synopsis

User credential object

{
    "email": "yi@jeplus.org",
    "password": "********"
}

Authorization return object

A successful authorization return object contains the status flag, message, user's name, email address, and a new JWT, as shown in the example below.

{
  "ok" : true,
  "status" : "User credential confirmed!",
  "jwt" : "Session key cookie",
  "user" : "Yi",
  "role" : "user",
  "email" : "yi@jeplus.org"
}

Confirmation Failed

If the supplied user credential does not match the current session, a Failed response will be received:

{
  "ok" : false,
  "status" : "User does not match the existing session"
}

Authorization Failed

An HTTP 401 - Unauthorized response will be received

Example using curl://

Assuming the session token has been saved in the cookies file using the log on command, send the confirm command using curl in Linux as below:

curl -b cookies -H 'Content-Type: application/json' -X POST -d '{"email": "yi@jeplus.org", "password": "********"}' https://api.ensims.com/users/api/confirm

If logged on successfully, an Auth return object with 'OK' status will be received with a new JWT. If the user's credential does not match the current session, a Failed object will be returned. If the session token is invalid, an HTTP 401 code will be returned.

Example using Python Requests

Make sure Requests is correctly installed in your Python environment, and run the following lines:

import requests

headers = {'Content-Type': 'application/json'}
body = {"email": "yi@jeplus.org", "password": "********"}

# Make a post request. Session token must be available in the saved cookies during log-on
r = requests.post('https://api.ensims.com/users/api/confirm', headers=headers, json=body, cookies=cookies)

# Show return info
r.json()

A successful operation will return the JSON content such as the following:

{
  "ok" : true,
  "status" : "User credential confirmed!",
  "jwt" : "Session key cookie",
  "user" : "Yi",
  "role" : "user",
  "email" : "yi@jeplus.org"
}