Adding Mobile Identity to your registration process

Before a user can use Mobile Identity to log in to your website, they will need to enrol an authentication device. In this scenario you will see how to add this enrolment to your already existing user registration process.

How does it work?

For this scenario, let's assume that you already have a way for a user to sign up on your website. Typically, this involves the user providing a username or email address. You might have additional steps after that, but for Mobile Identity, that's of little consequence. For the sake of this explanation, let's assume the registration process looks like this.

  1. The user enters a username.
  2. You create a new account for the user.
  3. The user indicates their notification preferences.
  4. The user fills out their profile.
  5. You take the user to the welcome page.

Your registration process may consist of only the first two steps, or it may have steps not mentioned here, or it may have these steps in a different order. It doesn't matter. As long as you create an account for the user, this will work.

You can insert the Mobile Identity enrolment anywhere into the process after the account has been created. Here's what that looks like.

  1. You generate a QR code.
  2. You show the QR code to the user.
  3. The user scans the QR code with the device they want to use as their authentication device.
  4. You wait until the user has scanned the QR code.

What parts of the API do you need?

Step by step

Where to start?

You will need to decide where in your registration process you will ask the user to enrol their authentication device. The rule to keep in mind: you must create an account for the user before you can show them a QR code since you need the UUID as a reference in later steps.

This means, you first need to ask the user for a username and create their account. After that, you can put the enrolment process wherever you like.

Of course, if you don't have any extra steps in your registration process, then the only possibility is: create an account, then enrol a device.

Obtain an access token

In order to call the Mobile Identity endpoints, you need to obtain an access token. If you want to know how to obtain an access token, please consult this page.

You need to specify the scopes of the access token or you won't be able to call the necessary endpoints. In this case, you need the following two:

  • credential:omi:enrol:qr:admin:post
  • credential:omi:enrol:status:get

Now, you may ask yourself: why do I need an access token if I want to use these APIs for doing a registration flow? Well, you need an access token with the above scopes so that we know that the application which is doing these calls is a trusted application. With this context in mind, we recommend you to use the oauth2 client credentials flow.

Generate a QR code

Before you can show a QR code to your user, you'll have to generate it, using the /omi/qr/enrol endpoint. The response of this API, as the API specification states, returns the QR code as a base64-encoded PNG image. You can show this on a webpage using the <img>-element. Just put the entire value in the src-attribute, prefixed with data:image/png;base64,.

HTML
CSS
Javascript
Copy

Check the status

Now it's up to the user to scan the QR code you're showing them. You can find out if they've done so by polling the endpoint /omi/qr/enrol/status. We recommend you poll every second or two, so you can act on the user's response quickly without overloading the servers.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
  Last updated by Ruud Vroon