Web integration

Once you've set up your organisation account on the Yoti Hub, you’re ready to start integrating with Yoti. This section explains how to complete a basic web integration.

Before you start
Please have a look at our best practices for a better performance of the SDK.
Good to know...
Following our user experience guidelines makes for a faster and more enjoyable experience for your users. Please read these sections before you continue.

QR Code type

You will need to create a button to allow your users to authenticate with Yoti. See Button design guide before you start the integration.

This contains a QR code for users to scan with their Yoti app. Mobile web users will skip the QR code scanning step, as they use the Yoti mobile app directly to authenticate. For more information on our modal go to our Integration guide.

Yoti has three options to display the QR code.

1) Modal

2) Instant

3) Inline

The modal QR code option has a button which when clicked opens a modal pop out window with the QR code present. There are three tabs, describing how to scan the QR code, The QR code and attributes to be shared and about Yoti - Please give it a click to see it working:

Inline

The inline QR code option has a button which when clicked opens just the QR code. You will need to provide more context as to what Yoti is for this. See scenario example section for more detail.

Instant

The instant QR code option is just the QR code with no button. You will need to provide more context as to what Yoti is for this. See scenario example section for more detail. Example below:

Generate a Yoti button

Yoti provides a button generator for you to include in your HTML file. In the example below, the button generator script has been added to the head of the HTML document.

To generate the Yoti button use the code snippet below:

Markdown
Markup
Javascript
Javascript
Copy

Inline

Markdown
Copy

Instant

mar
Copy

This JavaScript library currently needs to be invoked – do this by calling Yoti.Share.init() in the body of your HTML document. For the config, you will need to specify a ‘domId’ so we know where we need to add the Yoti button on your page and the ‘scenarioId’ that is being provided by Yoti Hub after creating an application.

The Yoti button requires the hosting page to be accessed via HTTPS, so please make sure that your web application has HTTPS enabled.

Finally, the domain port pair where the button is deployed (i.e. https://localhost:8000) must match the one that you have configured in Yoti Hub. This prevents other web sites from embedding your Yoti button.

NamePurposeRequired
domIDSpecifies the ID of the DOM node where Yoti webshare wants to be rendered.Yes
clientSdkIdIdentifies your Yoti Hub application. This value can be found in the Hub, within your application section, in the keys tab.Yes
scenarioIdIdentifies the attributes associated with your Yoti application. This value can be found on your application page in Yoti Hub (navigate to Scenarios tab)Yes
ButtonConfig for the button styling.No
Button - LabelText on the button. Should be relevant for your use case.No
Button - alignAlignment of the button in the parent div - "center", "left", "right"No
Button - widthWidth of the button - "auto" will set to fit the label. "full" - will fill the width of the parent div.No
Modal - zIndexSets the z-index of the modal. This is defaulted to 9999.No
shareCompleteAllows token handling to be performed without redirecting the webpage.No
shareComplete - closeDelayHow long the modal will stay open before handling the token or redirecting. Default to 4000ms with a min of 500ms and a max of 1000msNo
shareComplete - tokenHandlerAllows you to run your own function to handle the token without a redirect. Calling done() will close the modal; overwriting any closeDelay you have.No
labelThis is the text on the button and is customisableYes
titleThis is the text around the QR code and is customisableNo
Knowledge base
The redirected callback page will contain any existing query parameters at the time of the Yoti Share.
Before you continue
Please have a look at our best practices. We recommend taking them into account for a better performance of the SDK.

Install SDK

Once you have a working button, you can move on to installing the SDK. To successfully integrate you will need the following information about your application from Yoti Hub:

SDK ID

This is generated by Yoti when you publish your Yoti application in Yoti Hub. You can find it labelled as Yoti Client SDK ID under the Keys tab within your application. The SDK ID is necessary to initialise the Yoti SDK and it is passed in each call to our system.

Your application key pair

This is the private key (in .pem format) associated with the Yoti application you created in Yoti Hub.

There are three purposes for this PEM file:

  • Decrypting the one-time-use token.
  • Signing your requests to our system.
  • Decrypting the fetched user profile so that the profile data can be consumed by your application.

If you lose or corrupt your PEM file you will be able to generate a new one. Regenerating your key pair will break your current application by invalidating your current PEM file and generated keys. This means you will be unable to decrypt new tokens until these are replaced by the newly-generated ones.

The Yoti SDKs are available via popular dependency management systems. Further details can be found on the pages of the specific projects.

To install the Yoti SDK using NPM:

Javascript
Ruby
PHP
Python
Java
Go
C#
Copy

Once you have added the Yoti SDK dependency to your project, it’s time to initialise a Yoti client as shown in the code snippet below.

Javascript
Ruby
PHP
Python
Java
Go
C#
Copy
API Link
Jump straight to our API references with code snippets if you prefer.

Retrieve a profile

Retrieving a profile involves receiving a one-time-use token, and decrypting it to get a user profile.

When a user scans a Yoti QR code, Yoti makes a GET request to your callback URL, passing a token as a query string parameter.

For a URL set as https://your-callback-url in Yoti Hub, the returned callback URL would look like the following: https://your-callback-url?token=

You can set and edit the callback URL within your Yoti application under the Integration tab. Yoti will automatically prefix the URL with your domain.

When your web application receives a token via the exposed endpoint as a query string parameter, you can easily retrieve the user profile. The user profile object provides a set of attributes corresponding to the user attributes you specified during the creation of your Yoti application on Hub.

SDK process

When you pass the token to the Yoti Client object, the SDK does the following:

  • Decrypts the wrapped receipt key attribute, using the application private key.
  • Uses the decrypted key to decrypt the other party profile content attribute.
  • Decodes the decrypted profile and returns it to your application.

The profile attributes are central to the SDK and allow you to see and work with the information that your users share with you.

Javascript
Ruby
PHP
Python
Java
Go
C#
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard