API

Free Authentication Mock REST API Documentation

Free Authentication Mock REST API Documentation
117 views
2 min read
#API

The MockX Authentication API is designed to secure your applications by providing robust authentication mechanisms. This includes user login with username and password, token generation for session management, and user profile retrieval post-authentication. Here’s how to utilize these capabilities effectively.

Endpoints Overview

The Authentication API introduces essential endpoints for managing user authentication:

  • POST /login: Authenticates a user by their username and password.
  • GET /me: Retrieves the profile of the currently authenticated user.

Authenticate User

Authenticate a user and receive a token for session management.

POST https://api.mockx.net/auth/login

Body: username: The user's username. password: The user's password. expiresInMins (optional): The desired token expiration time in minutes. Example Request:

{
  "username": "user99",
  "password": "vxyd7p5w",
  "expiresInMins": 1440
}

Example Response:

{
  "id": 100,
  "username": "user99",
  "email": "user99@example.com",
  "firstName": "Jennifer",
  "lastName": "Jones",
  "gender": "female",
  "image": "hhttp://localhost:6578/auth/loginttps://api.multiavatar.com/avatar38.svg",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwLCJ1c2VybmFtZSI6InVzZXI5OSIsImVtYWlsIjoidXNlcjk5QGV4YW1wbGUuY29tIiwiZmlyc3ROYW1lIjoiSmVubmlmZXIiLCJsYXN0TmFtZSI6IkpvbmVzIiwiZ2VuZGVyIjoiZmVtYWxlIiwiaW1hZ2UiOiJodHRwczovL2FwaS5tdWx0aWF2YXRhci5jb20vYXZhdGFyMzguc3ZnIiwiaWF0IjoxNzEzODAzNTE4LCJleHAiOjE3MTM4ODk5MTh9.k0bI_FF5QolDUekF-V_2DAoLu8A2mLxQWvF4lwMOS7s"
}

Get Current User Profile

Retrieve the profile of the currently authenticated user using the token provided during login.

GET https://api.mockx.net/auth/me

Headers: Authorization: Bearer token Example Response:

{
  "id": 100,
  "firstName": "Jennifer",
  "lastName": "Jones",
  "maidenName": "Rowe",
  "age": 34,
  "gender": "female",
  "email": "user99@example.com",
  "phone": "+1 863 621 7440",
  "username": "user99",
  "password": "vxyd7p5w",
  "birthDate": "1959-03-27",
  "image": "https://api.multiavatar.com/avatar38.svg",
  "bloodGroup": "O-",
  "height": 186,
  "weight": 54.4,
  "eyeColor": "Brown",
  "hair": {
    "color": "Brown",
    "type": "Curly"
  },
  "domain": "user99domain.com",
  "ip": "41.139.56.18",
  "address": {
    "address": "3460 Street",
    "city": "Washington",
    "coordinates": {
      "lat": 77,
      "lng": -105
    },
    "postalCode": "27575",
    "state": "SomeState"
  },
  "macAddress": "14:f2:e1:1c:7e:1b",
  "university": "University of Example",
  "bank": {
    "cardExpire": "06/22",
    "cardNumber": "3565600124206309",
    "cardType": "jcb",
    "currency": "Krona",
    "iban": "FR19 2200 9407 28AH Q2CV AT31 S49"
  },
  "company": {
    "name": "ExampleCorp",
    "department": "Finance",
    "title": "Help Desk Operator"
  },
  "ein": "02-4892541",
  "ssn": "370-10-1238",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
  "crypto": {
    "coin": "Bitcoin",
    "wallet": "0xb9fc2fe63b2a6c003f1c324c3bfa53259162181a",
    "network": "Ethereum (ERC20)"
  }
}
MockX offers free, reliable mock APIs for easy testing and development, ideal for developers seeking to enhance their workflow without the complexities of setting up any server.
Copyright © 2024. Made with ♥ by MockX.net