Skip to content

Instantly share code, notes, and snippets.

@sahilkashyap64
Created October 11, 2021 10:23
Show Gist options
  • Save sahilkashyap64/733ed61d351fd2344e4fa00a0dbff783 to your computer and use it in GitHub Desktop.
Save sahilkashyap64/733ed61d351fd2344e4fa00a0dbff783 to your computer and use it in GitHub Desktop.

QR Laravel login

Indices


QR LOGIN AJAX POLLING

QR Login using AJAX Polling

1. 1. Create Qrcode

Create QRcode image

Endpoint:

Method: POST
Type: 
URL: http://127.0.0.1:8000/api/login/create/qrcode

More example Requests/Responses:

I. Example Request: 1. Create Qrcode

Headers:

Key Value Description
Accept application/json
I. Example Response: 1. Create Qrcode
{
    "status": 1,
    "msg": "http://127.0.0.1:8000/assets/img/qrcodeimg/LAMi2MpANGoMxZeDYzHNzXnyaNltVg.png",
    "key": "LAMi2MpANGoMxZeDYzHNzXnyaNltVg"
}

Status Code: 200


2. 2. check QR code scan status

Poll this API to check QR has been scanned or not.

Endpoint:

Method: POST
Type: FORMDATA
URL: http://127.0.0.1:8000/api/login/scan/qrcode

Headers:

Key Value Description
Accept application/json

Body:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg key from Create Qrcode api

More example Requests/Responses:

I. Example Request: QR code not scanned status 0

Headers:

Key Value Description
Accept application/json

Body:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg key from Create Qrcode api
I. Example Response: QR code not scanned status 0
{
    "status": 0,
    "msg": ""
}

Status Code: 200


II. Example Request: QR code scaned successful

Headers:

Key Value Description
Accept application/json

Body:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg key from Create Qrcode api
II. Example Response: QR code scaned successful
{
    "status": 1,
    "msg": "success"
}

Status Code: 200


3. 3. Mobile device scan code

Use QRScanner app to scan the QR code and attach the user passcode in headers and hit this url

Endpoint:

Method: POST
Type: 
URL: http://127.0.0.1:8000/api/login/mobile/scan/qrcode

Headers:

Key Value Description
userpasscode b8rv4pvqBg user's passcode attached from authenticated qrscanner app

Query params:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg key from create qrcode app
type 1 required

More example Requests/Responses:

I. Example Request: Expired

Headers:

Key Value Description
userpasscode b8rv4pvqBg user's passcode attached from authenticated qrscanner app

Query:

Key Value Description
key dfhcSlugAQ9dyu7ZtAYAHGcWGzltBB key from create qrcode app
type 1 required
I. Example Response: Expired
{
    "status": 2,
    "msg": "expired"
}

Status Code: 200


II. Example Request: QR code scanned by QR scanner

Headers:

Key Value Description
userpasscode b8rv4pvqBg user's passcode attached from authenticated qrscanner app

Query:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg key from create qrcode app
type 1 required
II. Example Response: QR code scanned by QR scanner
{
    "status": 1,
    "msg": "http://127.0.0.1:8000/api/login/qrcodedoLogin?key=LAMi2MpANGoMxZeDYzHNzXnyaNltVg&type=scan&login=b8rv4pvqBg&sign=ALwnx7oK47jb"
}

Status Code: 200


4. 4. qrcodedoLogin2 [success response from 3. mobile device scan]

Endpoint:

Method: POST
Type: 
URL: http://127.0.0.1:8000/api/login/qrcodedoLogin

Query params:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg QR code key
type scan scanned successfully
login b8rv4pvqBg user's passcode
sign ALwnx7oK47jb unique identification: system generated

More example Requests/Responses:

I. Example Request: Login succesfull

Query:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg QR code key
type scan scanned successfully
login b8rv4pvqBg user's passcode
sign ALwnx7oK47jb unique identification: system generated
I. Example Response: Login succesfull
{
    "status": 1,
    "msg": "Login successful"
}

Status Code: 200


5. 5. poll api/login/entry/login

Poll this API to check QR has been logged in or not.

Endpoint:

Method: POST
Type: FORMDATA
URL: http://127.0.0.1:8000/api/login/entry/login

Body:

Key Value Description
key dfhcSlugAQ9dyu7ZtAYAHGcWGzltBB QR code key
deviceid rewsjjj device id

More example Requests/Responses:

I. Example Request: Successfull

Headers:

Key Value Description
Accept application/json

Body:

Key Value Description
key LAMi2MpANGoMxZeDYzHNzXnyaNltVg QR code key
deviceid 12434sf3 device id
I. Example Response: Successfull
{
    "success": true,
    "message": "logged in successfully ",
    "response_code": 200,
    "connected_device": "7 device connected  ",
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjE6ODAwMFwvYXBpXC9sb2dpblwvZW50cnlcL2xvZ2luIiwiaWF0IjoxNjMzOTQ1ODE0LCJleHAiOjE2MzY1NzM4MTQsIm5iZiI6MTYzMzk0NTgxNCwianRpIjoiN1FRekR4M0dxWjlpTXVaRiIsInN1YiI6MzQsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEiLCJuYW1lIjoic2FoaWwgdHJpYWwiLCJyb2xlcyI6W3siaWQiOjUsIm5hbWUiOiJ0aWVydXNlciIsImRpc3BsYXlfbmFtZSI6InRpZXIgdXNlciIsImRlc2NyaXB0aW9uIjoidGllciB1c2VyIHBlcm1pc3Npb24iLCJjcmVhdGVkX2F0IjpudWxsLCJ1cGRhdGVkX2F0IjpudWxsLCJwaXZvdCI6eyJ1c2VyX2lkIjozNCwicm9sZV9pZCI6NX19XX0.9Pq1earu0ko9tMQEIpDpTalg5MqbUGbVktXWfHBoXBg",
    "token_type": "bearer",
    "expires_in": 2628000,
    "device_info": "PostmanRuntime#~12434sf3",
    "user": {
        "id": 34,
        "provider_name": null,
        "provider_id": null,
        "name": "sahil trial",
        "email": "[email protected]",
        "contact": null,
        "gender": null,
        "dob": null,
        "zipcode": "99583",
        "address": null,
        "country": "",
        "google_id": null,
        "last_login": null,
        "email_verified_at": "2020-07-24 04:16:20",
        "is_active": 1,
        "created_at": "2020-07-20 22:45:37",
        "updated_at": "2021-07-16 17:02:07",
        "stripe_id": "cus_JdQYPv5NAylLHw",
        "card_brand": "visa",
        "card_last_four": "4242",
        "trial_ends_at": null,
        "avatar": null,
        "roles": [
            {
                "id": 5,
                "name": "tieruser",
                "display_name": "tier user",
                "description": "tier user permission",
                "created_at": null,
                "updated_at": null,
                "pivot": {
                    "user_id": 34,
                    "role_id": 5
                }
            }
        ]
    },
    "termandcondition": false,
    "rooms": [
        {
            "id": 33,
            "user_id": 34,
            "hotel_room": "Room8",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-08-06 15:05:07"
        },
        {
            "id": 32,
            "user_id": 34,
            "hotel_room": "Room7",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-07-13 12:33:42"
        },
        {
            "id": 31,
            "user_id": 34,
            "hotel_room": "Room6",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-07-13 12:33:42"
        },
        {
            "id": 30,
            "user_id": 34,
            "hotel_room": "Room5",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-07-13 12:33:42"
        },
        {
            "id": 29,
            "user_id": 34,
            "hotel_room": "Room4",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-07-13 12:33:42"
        },
        {
            "id": 28,
            "user_id": 34,
            "hotel_room": "Room3",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-07-13 12:33:42"
        },
        {
            "id": 27,
            "user_id": 34,
            "hotel_room": "Room2",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-07-13 12:33:42"
        },
        {
            "id": 26,
            "user_id": 34,
            "hotel_room": "Room1",
            "session_id": null,
            "created_on": "2021-07-13 12:33:42",
            "modified_on": "2021-07-13 12:33:42"
        }
    ],
    "userrole": "tieruser"
}

Status Code: 200


Available Variables:

Key Value Type
baseUrl http://127.0.0.1:8000

Back to top

Made with ♥ by thedevsaddam | Generated at: 2021-10-11 15:41:06 by docgen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment