Skip to content

ishafiul/passwordless-auth

Repository files navigation

Passwordless Authentication

End-point: Create Device UUID

this API will create device UUID.

here userType, deviceType, appInfo, and ipAddress are required.

userType is a enum of

enum UserType  {
    ADMIN,
    USER
}

Method: POST

{{localhost}}/auth/create-device-uuid

Body (raw)

{
    "userType": "ADMIN",
    "deviceType": "WEB",
    "osVersionCode": "mac",
    "osVersionRelease": "12.2",
    "deviceBrand": "Apple",
    "deviceModel": "macbook pro m1",
    "deviceManufacturer": "Apple",
    "appInfo": {
        "versionName": "1.0.0",
        "versionCode": "1"
    },
    "location": {
        "coordinates": [0, 0]
    },
    "ipAddress": "172.0.0.1"
}

Response

{
    "status": "CREATED",
    "message": "device uuid created successfully",
    "data": {
        "deviceUuId": "U2FsdGVkX1/KctaimzBiCz9wmdmD1g9mO6k9WrMW59iS43Z2RHH8H10q2wU3fnLHJXwZ6TX8XK2n2g+pNLSwI/4reW1W2qaMtDhSpNwIOrHteIqS1hkO0bgillTNEroVeSgQ2jb7xZ/yUUPewX1LGd4NNINzoJCc+bJJAUsn0GMdaRZK5sVE9gOUnyBbMmfFHpWb7cEMvZ/NrYhi3e7hA7ZB25JsRLOYLCYYt3vze0E/Pza4A2viL9opB9d70wR0/DCeOv/5nW94M9ZNWvk850eWOndmDZBrBRyNed8bMRAj+8msqxHvtQJOFEV96QV0YfKKvjPShlkp+1ED1yuihVGtvmjhSSCIDlsHfJmCdlZBSakceKfZ4jAFPE0WIT1/d8y8aBmuJ88EsVlIiq0L8aci8uDGxQw+hG2dKpIv3xo="
    }
}

⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃

End-point: Request OTP

here user can request OTP for login or signup. if there is no user with this email, the system will create a signup OTP.

Method: POST

{{localhost}}/auth/req-otp

Body (raw)

{
    "email":"[email protected]",
    "deviceUuid": "U2FsdGVkX1/heJpO2ngP1VM8TBXHWVBLx6KzTvhZFktJhMEtRgFKkWqCPDdXQm5KjW5KX92kypQC4c5kTD00EgwGNagvFFVNpoTMJ3Q+w3dAax13UjNQ3C+xjYUvji9MXIy22P4VttM+j4q5Ro0lTdEXrjSQjsraE+Xlahvq2kGcwoq4Jkr0wD769Vgz+04wpRurcjhK4kYw5WBqymalXGcYinYJf2fjvxbJhtIds89Z7G+S6Etkio6CVyXEowGOWb51Gp+0mvtUAEwUdCbF7p8/4rETEx+o3Bozr0siXQg2J8xF2Pur3v9DFKJoR6SbJ7shV39oWINwn5csNBtrb3I1nbJclVyLczeqg1Qpqkou+HTAhDQBhIHdP3uNraMR0NVLGfUIbYX7BHKbe6Bm6gycYrMqyrQxFpEKNo+oSn8="
}

Response

{
    "status": "CREATED",
    "message": "Login Otp Send",
    "data": ""
}

⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃

End-point: Verify OTP

if the OTP is valid it will return access tokens. if the OTP is valid and there is no user with this email, the system will create a new user.

here, one user can only use one device login at the same time. other access tokens will be expire and other device login will be expire

Method: POST

{{localhost}}/auth/verify-otp

Body (raw)

{
    "otp": "38228",
    "email":"[email protected]",
    "deviceUuid": "U2FsdGVkX1/heJpO2ngP1VM8TBXHWVBLx6KzTvhZFktJhMEtRgFKkWqCPDdXQm5KjW5KX92kypQC4c5kTD00EgwGNagvFFVNpoT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 ⁃ ⁃ ⁃ ⁃ ⁃ ⁃

End-point: Refresh Token

with this system, one user can only use one device login at the same time. other access tokens will be expired.

Method: POST

{{localhost}}/auth/refresh-token

Body (raw)

{
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2Mzk4NjFjYzE5MDVhNjA2ZmU2Y2M4OWYiLCJlbWFpbCI6InNoYWZpdWxpc2xhbTIwQGdtYWlsLmNvbSIsImlhdCI6MTY3MDkzMjgzNSwiZXhwIjoxNjcwOTMzMTM1fQ.5t3BMrpU35NUHRWcSt-uCyBT8WijmBo1kVRyPYsU6HY",
    "deviceUuId": "U2FsdGVkX1/heJpO2ngP1VM8TBXHWVBLx6KzTvhZFktJhMEtRgFKkWqCPDdXQm5KjW5KX92kypQC4c5kTD00EgwGNagvFFVNpoTMJ3Q+w3dAax13UjNQ3C+xjYUvji9MXIy22P4VttM+j4q5Ro0lTdEXrjSQjsraE+Xlahvq2kGcwoq4Jkr0wD769Vgz+04wpRurcjhK4kYw5WBqymalXGcYinYJf2fjvxbJhtIds89Z7G+S6Etkio6CVyXEowGOWb51Gp+0mvtUAEwUdCbF7p8/4rETEx+o3Bozr0siXQg2J8xF2Pur3v9DFKJoR6SbJ7shV39oWINwn5csNBtrb3I1nbJclVyLczeqg1Qpqkou+HTAhDQBhIHdP3uNraMR0NVLGfUIbYX7BHKbe6Bm6gycYrMqyrQxFpEKNo+oSn8="
}

Response

{
    "status": "SUCCESS",
    "message": "Token Created Successfully!",
    "data": {
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2Mzk4NjFjYzE5MDVhNjA2ZmU2Y2M4OWYiLCJlbWFpbCI6InNoYWZpdWxpc2xhbTIwQGdtYWlsLmNvbSIsImlhdCI6MTY3MDkzMjg0OCwiZXhwIjoxNjcwOTMyOTA4fQ.RAqEy07mrz-ZPWe7tFIMnggDY4dyiugveh1HmN3pswo",
        "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2Mzk4NjFjYzE5MDVhNjA2ZmU2Y2M4OWYiLCJlbWFpbCI6InNoYWZpdWxpc2xhbTIwQGdtYWlsLmNvbSIsImlhdCI6MTY3MDkzMjg0OCwiZXhwIjoxNjcwOTMzMTQ4fQ.2kRRqaJE94EZq_iEDsb5gBvR5cMg5y7fS2_IyCAPZwc"
    }
}