Login

This endpoint allows users to log in to the Digital Identity system using their phone number and password. If the user is logging in from a new device, they may be required to enter an OTP sent via SMS.

Workflow for Login Endpoint

  1. User Initiates Login: The user sends a POST request to the /Login endpoint with their geoLocation, imei, phoneNumber, and password.

  2. Server Validation:

    • The server validates the provided phoneNumber and password.

    • If logging in from a new device, the server may require an OTP sent to the user's phone number.

  3. Response:

    • If the credentials are correct and any required OTP is verified, the server responds with an access token and user details.

    • If the credentials or OTP are incorrect, or any required fields are missing, an appropriate error response is returned.

User login to the Digital Identity system

post
Body
phoneNumberstringRequired
passwordstring | nullableOptional
imeistringRequired
imsistring | nullableOptional
phoneNumberOtpRequestIdstring | nullableOptional
phoneNumberOtpstring | nullableOptional
isPhone2FAEnabledbooleanOptional
smsProviderinteger · enumOptionalPossible values:
Responses
200

Success

post
/api/DigitalIdentity/Login
POST /api/DigitalIdentity/Login HTTP/1.1
Host: 
Content-Type: application/json-patch+json
Accept: */*
Content-Length: 209

{
  "phoneNumber": "text",
  "password": "text",
  "geoLocation": {
    "latitude": 1,
    "longitude": 1
  },
  "imei": "text",
  "imsi": "text",
  "phoneNumberOtpRequestId": "text",
  "phoneNumberOtp": "text",
  "isPhone2FAEnabled": true,
  "smsProvider": 1
}
200

Success

{
  "data": {
    "hasPendingRequest": true,
    "isEmailConfirmationRequired": true,
    "isEmailConfirmed": true,
    "isPhoneNumberConfirmationRequired": true,
    "isPhoneNumberConfirmed": true,
    "phoneNumberOtp": "text",
    "phoneNumberOtpRequestId": "123e4567-e89b-12d3-a456-426614174000",
    "emailOtpRequestId": "123e4567-e89b-12d3-a456-426614174000",
    "isDigitalIdentityVerified": true,
    "accessToken": "text",
    "refreshToken": "text",
    "encryptedAccessToken": "text",
    "phoneOtpExpireInSeconds": 1,
    "emailOtpExpireInSeconds": 1,
    "user": {
      "id": 1,
      "name": "text",
      "surname": "text",
      "fullName": "text",
      "userName": "text",
      "emailAddress": "text",
      "phoneNumber": "text",
      "idNumber": "text",
      "address": "text"
    },
    "redirectUri": "text",
    "transactionId": "123e4567-e89b-12d3-a456-426614174000"
  },
  "error_code": 1,
  "error_message": "text",
  "error_descriptions": null
}

To refresh the access token upon its expiration, you can use the below endpoint.

post
Body
refreshTokenstring | nullableOptional
Responses
200

Success

post
/api/DigitalIdentity/RefreshToken
POST /api/DigitalIdentity/RefreshToken HTTP/1.1
Host: 
Content-Type: application/json-patch+json
Accept: */*
Content-Length: 23

{
  "refreshToken": "text"
}
200

Success

{
  "data": {
    "refreshToken": "text",
    "newRefreshToken": "text",
    "accessToken": "text",
    "encryptedAccessToken": "text",
    "expireInSeconds": 1
  },
  "error_code": 1,
  "error_message": "text",
  "error_descriptions": null
}

Admin login to the Digital Identity system

post
Body
tenancyNamestring · max: 256Required
userNameOrEmailAddressstring · max: 256Required
passwordstring · max: 32Required
Responses
200

Success

post
/api/credentials/Login
POST /api/credentials/Login HTTP/1.1
Host: 
Content-Type: application/json-patch+json
Accept: */*
Content-Length: 72

{
  "tenancyName": "text",
  "userNameOrEmailAddress": "text",
  "password": "text"
}
200

Success

{
  "data": {
    "accessToken": "text",
    "encryptedAccessToken": "text",
    "expireInSeconds": 1,
    "shouldResetPassword": true,
    "passwordResetCode": "text",
    "userId": 1,
    "requiresTwoFactorVerification": true,
    "twoFactorAuthProviders": [
      "text"
    ],
    "twoFactorRememberClientToken": "text",
    "returnUrl": "text",
    "refreshToken": "text",
    "refreshTokenExpireInSeconds": 1
  },
  "error_code": 1,
  "error_message": "text",
  "error_descriptions": null
}

To refresh the access token upon its expiration, you can use the below endpoint.

post
Body
refreshTokenstring | nullableOptional
Responses
200

Success

post
/api/credentials/RefreshToken
POST /api/credentials/RefreshToken HTTP/1.1
Host: 
Content-Type: application/json-patch+json
Accept: */*
Content-Length: 23

{
  "refreshToken": "text"
}
200

Success

{
  "data": {
    "refreshToken": "text",
    "newRefreshToken": "text",
    "accessToken": "text",
    "encryptedAccessToken": "text",
    "expireInSeconds": 1
  },
  "error_code": 1,
  "error_message": "text",
  "error_descriptions": null
}
import axios from 'axios';

const BASE_URL = "https://api.vlenseg.com/api/DigitalIdentity/Login";
const API_KEY = "your_api_key_here";
let lat = "device lat"
let long = "device long"

const data = {
    geoLocation: {
        latitude: lat,
        longitude: long
    },
    imei: "123456789012345",
    phoneNumber: "user phone",
    password: "password"
};

try {
    const response = await axios.post(BASE_URL, data, {
        headers: {
            'Content-Type': 'application/json',
            'ApiKey': API_KEY
        }
    });
    console.log(response.data);
} catch (error) {
    console.error(error.response ? error.response.data : error.message);
}

Last updated