XPM

Login Local User

Path:

POST /auth/local/login

Registered users can login to the site using their own credentials (email and password). Unlike guest users, logged in users can save their settings, preferences, and additionally build a persistent cart, track orders, view order history, add/update wish list, etc.

In response, customer details are retrieved along with the JSON Web Token (JWT) authentication, which is your digital signature of authorization. It defines a compact and self-contained way for securely transmitting information. It is essential to run the subsequent calls.

Headers

Content-Type: application/json

x-site-context: {"channel1":1,"date":"2019-06-19"}

Consumes

  • application/json

Produces

  • application/json

Parameters

Type: Body

Name: Login Credentials

Required: true

Sample

{
"username" : "johnsmith@fabric.inc",
"password" :"ExamplePassword123!"
}

Responses

HTTP Code: 200 Message: OK

Description: You will see this message when login credentials are successfully validated.

Sample:

{
"_id": "5e97947d3cb8553c0e43d87f",
"userId": 90,
"roles": [
{
"id": "5de1646f8c6352091d944f1c"
}
],
"name": {
"first": "John",
"middle": "A",
"last": "Smith"
},
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVlOTc5NDdkM2NiODU1M2MwZTQzZDg3ZiIsInJvbGVzIjpbeyJpZCI6IjVkZTE2NDZmOGM2MzUyMDkxZDk0NGYxYyJ9XSwiaWF0IjoxNTg2OTkyODUyLCJleHAiOjE1ODY5OTQ2NTJ9.KGGW4Ij8PpnIgj0r_xX8BAYTpgcqOV9vJNx16zNhe_gBBaiqvwUdHKPcrrAU-D6PxU4k3n7LCEghf6V0kvAoSA",
"refreshToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVlOTc5NDdkM2NiODU1M2MwZTQzZDg3ZiIsImlhdCI6MTU4Njk5Mjg1MiwiZXhwIjoxNTkwODgwODUyfQ.RSn_7schigJey3iLeJq0XXNGbxkrxRJYGykYvY_LIRtMk-6qBtxy7kII9-EOKYzaldV0rRpjzMhG16Ov2XePlA"
}

HTTP Code: 400 Message: Bad Request

Description: You will see this message when the login credentials cannot be validated; either the username or password, or both are incorrect.

Sample:

{
"code": "LOCAL_AUTH_FAILED",
"message": "Username or Password is Invalid."
}

Changelog

  • Last updated - July 2020