## DeviceAtlas Device Verification QR Code ##
- [Basic Configurations](#basic-configurations)
- [Example](#basic-configurations-example)
- [Changing iframe size](#changing-iframe-size)
- [Example Response](#example-response)
- [Advanced Configurations](#advanced-configurations)
- [Examples](#all-examples)
- [All Configurations](#all-configurations)
- [Redirect Device Only](#redirect-device-only)
- [Redirect Host Only](#redirect-host-only)
- [Redirect Host and Device](#redirect-device-host)
- [Auto Refresh](#example-auto-refresh-with-a-delay-showing-a-custom-scan-message-and-redirect-the-scanning-device)
- [Troubleshooting](#troubleshooting)
This guide will help you to create a QR code for a website using DeviceAtlas Device Verification QR Code. The QR code snippet will allow
you to display a QR code on a website when scanned with a mobile device.
Basic Configurations
| Query Parameter | Type | Constraints | Description |
|-----------------|---------|------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| dv-size | integer | Min: **50**
Max: **500**
Default: **250** | Sets the width and height of the QR code. |
| dv-json | boolean | **true** or **false**
Default: **false** | This will hide and remove the iframe after a mobile scan is shown. A function called: `_deviceAssureResultReceived` will need to be defined to use the result in the originating page. |
| dv-licenceKey | string | Required for licence specific property set and extended configurations | This is required to return the properties configured for this licence and to enable extended configurations. |
Example
The QR Code will be inserted in to an iframe within the div with the id `deviceassure`.
The result of the scan will be returned to the originating page using the `_deviceAssureResultReceived` function.
```html
```
---
Changing iframe size
By default the iframe is created with a width and height of 500px. You can change this by adding some CSS to override the default values.
```css
/* Optional styling for the iframe */
#deviceassure-iframe {
width: 325px;
height: 325px;
}
/* Centered the contents in the QR div */
#deviceassure {
display: flex;
justify-content: center;
align-items: center;
}
```
---
Example Response
This is an example of the response that will be returned to the originating page when the QR code is scanned.
```json
{
"type": "com.deviceassure.payload.result",
"data": {
"code": "bd3f41f0-ace0-4c77-ae33-da195f2675ff",
"deviceAssure": {
"result": "AUTHENTIC",
"reason": "Properties match",
"deviceAtlasProperties": {
"vendor": "Google",
"marketingName": "Pixel 6a"
},
"referenceId": "871d26e2-94fb-400a-92ab-3b9a672b4c53"
},
"meta": {}
}
}
```
#### Response Format: ####
| Property | Type | Description |
|-------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| type | string | The type of response returned. This is used for the behaviour of the QR code. It can be one of the following:
`com.deviceassure.payload.result`- default response
`com.deviceassure.payload.redirect` - redirect response
`com.deviceassure.payload.reload` - auto-refresh response |
| data | object | Data for the response, usually contains DeviceAssure response and code id |
| data.code | string | ID for the QR Code |
| data.deviceAssure | object | The DeviceAssure response. Please consult the Implementation Guide for more in depth descriptions. |
---
Advanced Configurations
In addition to the Basic Configurations, there are more advanced configurations that can be used to customise the QR code.
The dv-licenceKey parameter is required for these advanced configurations.
The option to configure these configurations is available upon request [here](mailto:support@deviceassure.com).
| Query Parameter | Type | Default | Constraints | Description |
|--------------------|--------|------------------|--------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| dv-lifecycle | string | _default_ | _default_ or _auto-refresh_ | Describes how the QR host will behave by _default_, a click to refresh message is shown once scanned.
If set to _auto-refresh_, the scanned QR code will be replaced with a new code automatically. |
| dv-response-delay | number | 2000 | Values must be non-negative and in milliseconds. | The time delay after a scan. Usually used in conjunction with the auto-refresh lifecycle and host-redirect in order to show a message before transitioning. |
| dv-redirect | string | | | A URL for the host showing the QR code to redirect to after a scan. When redirected, the URL will have a query param called _response_ with a base64 string of the JSON response as its value. |
| dv-device-redirect | string | | | A URL for the device to redirect to after a scan. When redirected, the URL will have a query param called _response_ with a base64 string of the JSON response as its value. |
| dv-scanned-message | string | Code was scanned | | Message to show after a QR code is successfully scanned. |
| dv-expired-message | string | Code has expired | | Message to show after a QR code expires. |
---
Examples
All Configurations
This example will:
- Show a QR Code
- Show the custom 'Example Page Scanned' message on the originating page
- Refresh the QR code after 2000 milliseconds
- Scanning device will be redirected to the configured `dv-device-redirect` URL. The URL will have a query param called response with a base64 string of the JSON response as its value
- Host device will be redirect to the configured `dv-redirect` URL. the URL will have a query param called response with a base64 string of the JSON response as its value
-The `_deviceAssureResultReceived` function will be called with the result of the scan
```html
```
---
Device Only Redirect
#### Host setup: ####
```html
```
#### Redirect page setup: ####
The redirect page will need to decode the base64 string and parse the JSON object to get the DeviceAssure response.
An example of the URL that will be redirected to is as follows
```
https://www.example-redirect.com?response=ewogICJjb2RlIjogImJkM2Y0MWYwLWFjZTAtNGM3Ny1hZTMzLWRhMTk1ZjI2NzVmZiIsCiAgImRldmljZUFzc3VyZSI6IHsKICAgICJyZXN1bHQiOiAiQVVUSEVOVElDIiwKICAgICJyZWFzb24iOiAiUHJvcGVydGllcyBtYXRjaCIsCiAgICAiZGV2aWNlQXRsYXNQcm9wZXJ0aWVzIjogewogICAgICAidmVuZG9yIjogIkdvb2dsZSIsCiAgICAgICJtYXJrZXRpbmdOYW1lIjogIlBpeGVsIDZhIgogICAgfSwKICAgICJyZWZlcmVuY2VJZCI6ICI4NzFkMjZlMi05NGZiLTQwMGEtOTJhYi0zYjlhNjcyYjRjNTMiCiAgfSwKICAibWV0YSI6IHt9Cn0
```
#### Decoded Response for Redirects: ####
Below is the format for a redirect. Note how the redirect format is not nested.
```json
{
"code": "bd3f41f0-ace0-4c77-ae33-da195f2675ff",
"deviceAssure": {
"result": "AUTHENTIC",
"reason": "Properties match",
"deviceAtlasProperties": {
"vendor": "Google",
"marketingName": "Pixel 6a"
},
"referenceId": "871d26e2-94fb-400a-92ab-3b9a672b4c53"
},
"meta": {}
}
```
#### Response Format: ####
| Property | Type | Description |
|--------------|--------|----------------------------------------------------------------------------------------------------|
| code | string | ID for the QR Code |
| deviceAssure | object | The DeviceAssure response. Please consult the Implementation Guide for more in depth descriptions. |
The following code snippet demonstrates how to decode the base64 string and display the DeviceAssure response.
```html
```
---
Host Only Redirect
#### Host setup: ####
```html
```
#### Redirect page setup: ####
The redirect page will need to decode the base64 string and parse the JSON object to get the DeviceAssure response.
An example of the URL that will be redirected to is as follows
```
https://www.example-redirect.com?response=ewogICJjb2RlIjogImJkM2Y0MWYwLWFjZTAtNGM3Ny1hZTMzLWRhMTk1ZjI2NzVmZiIsCiAgImRldmljZUFzc3VyZSI6IHsKICAgICJyZXN1bHQiOiAiQVVUSEVOVElDIiwKICAgICJyZWFzb24iOiAiUHJvcGVydGllcyBtYXRjaCIsCiAgICAiZGV2aWNlQXRsYXNQcm9wZXJ0aWVzIjogewogICAgICAidmVuZG9yIjogIkdvb2dsZSIsCiAgICAgICJtYXJrZXRpbmdOYW1lIjogIlBpeGVsIDZhIgogICAgfSwKICAgICJyZWZlcmVuY2VJZCI6ICI4NzFkMjZlMi05NGZiLTQwMGEtOTJhYi0zYjlhNjcyYjRjNTMiCiAgfSwKICAibWV0YSI6IHt9Cn0
```
The following code snippet demonstrates how to decode the base64 string and display the DeviceAssure response.
```html
```
---
Host and Device Redirect
#### Host setup: ####
```html
```
#### Redirect page setup: ####
The redirect page will need to decode the base64 string and parse the JSON object to get the DeviceAssure response.
An example of the URL that will be redirected to is as follows
```
https://www.example-redirect.com?response=ewogICJjb2RlIjogImJkM2Y0MWYwLWFjZTAtNGM3Ny1hZTMzLWRhMTk1ZjI2NzVmZiIsCiAgImRldmljZUFzc3VyZSI6IHsKICAgICJyZXN1bHQiOiAiQVVUSEVOVElDIiwKICAgICJyZWFzb24iOiAiUHJvcGVydGllcyBtYXRjaCIsCiAgICAiZGV2aWNlQXRsYXNQcm9wZXJ0aWVzIjogewogICAgICAidmVuZG9yIjogIkdvb2dsZSIsCiAgICAgICJtYXJrZXRpbmdOYW1lIjogIlBpeGVsIDZhIgogICAgfSwKICAgICJyZWZlcmVuY2VJZCI6ICI4NzFkMjZlMi05NGZiLTQwMGEtOTJhYi0zYjlhNjcyYjRjNTMiCiAgfSwKICAibWV0YSI6IHt9Cn0
```
The following code snippet demonstrates how to decode the base64 string and display the DeviceAssure response.
```html
```
---
Auto refresh with a delay, showing a custom scan message and redirect the scanning device
This example will:
- Show a QR Code
- Show the custom 'Device Scanned' message on the originating page
- Refresh the QR code after 2000 milliseconds
- Redirect the device to configured URL after a scan
- Return the configured DeviceAssure response for the licence key
- The `_deviceAssureResultReceived` function will be called with the result of the scan
#### Host setup: ####
```html
```
#### Redirect page setup: ####
The redirect page will need to decode the base64 string and parse the JSON object to get the DeviceAssure response.
An example of the URL that will be redirected to is as follows
```
https://www.example-redirect.com?response=ewogICJjb2RlIjogImJkM2Y0MWYwLWFjZTAtNGM3Ny1hZTMzLWRhMTk1ZjI2NzVmZiIsCiAgImRldmljZUFzc3VyZSI6IHsKICAgICJyZXN1bHQiOiAiQVVUSEVOVElDIiwKICAgICJyZWFzb24iOiAiUHJvcGVydGllcyBtYXRjaCIsCiAgICAiZGV2aWNlQXRsYXNQcm9wZXJ0aWVzIjogewogICAgICAidmVuZG9yIjogIkdvb2dsZSIsCiAgICAgICJtYXJrZXRpbmdOYW1lIjogIlBpeGVsIDZhIgogICAgfSwKICAgICJyZWZlcmVuY2VJZCI6ICI4NzFkMjZlMi05NGZiLTQwMGEtOTJhYi0zYjlhNjcyYjRjNTMiCiAgfSwKICAibWV0YSI6IHt9Cn0
```
The following code snippet demonstrates how to decode the base64 string and display the DeviceAssure response.
```html
```
---
Troubleshooting
QR Code Redirects
When using the redirect functionality with the DeviceAtlas QR Code, it is important to ensure that the `dv-device-redirect`
is accessible to the scanning device.
The following urls won't work out of the box:
- localhost
- 127.0.0.1
- 0.0.0.0
It would be best to use a network IP address or a domain name that is accessible to the scanning device.
---
## Copyright ##
Copyright (c) DeviceAtlas Limited 2024. All rights reserved. https://deviceatlas.com