See api-docs Menu

Multi-Factor Authentication API

Adding Mutli-Factor Authentication (MFA) to your application is a sure fire way to increase security and prevent unauthorized access to user accounts. The most common workflows for MFA is to complete pre-registration for MFA or add an additional layer of security at login time. However using these API’s you can add MFA verification to any process that would benefit from additional security.

OneLogin provides a series of API endpoints that let you manage MFA for your users. With these APIs you can register and verify a variety of different MFA factors.

MFA API’s are availble for the following factors:

  • OneLogin SMS
  • OneLogin Voice
  • OneLogin Protect
  • OneLogin Email
  • Google Authenticator, or any authenticator that uses Key URI Format.

Depending on the factor, the verification will need to be done by submitting a token or by polling the status to determine if the user has completed MFA.

Verify factor with token

This requires the end user to receive an OTP code through the factor, and then use that code to complete MFA as part of the original flow. This is typical for the following factors:

  • OneLogin SMS
  • OneLogin Protect when using OTP
  • OneLogin Email
  • Google Authenticator

Factor Registration

Get Available Factors

Enroll a Factor

Verify Enrollment of a Factor

Factor Verification

Get Enrolled Factors

Activate a Factor

Verify a Factor

Verify factor with polling

For OneLogin Protect and OneLogin Voice the user will complete MFA without submitting an OTP to the verification API. For these factors you can poll for the status to determine when the factor has been completed successfully. For OneLogin Voice the end user will enter the OTP code into their phone, and with OneLogin Protect they will complete MFA by accepting or rejecting the push notification request.

  • OneLogin Protect when using push notifications
  • OneLogin Voice

Factor Registration

Get Available Factors

Enroll a Factor

Verify Enrollment of a Factor

Factor Verification

Get Enrolled Factors

Activate a Factor

Verify a Factor

Postman Collection

Replace sample variables indicated by {{ }} with your actual values.

Download for the MFA API

Sample Workflow

Passwordless login using MFA

To provide OneLogin authentication with MFA in your app’s authentication flow, your app must do the following:

  1. Get a bearer access token, using the Generate Tokens v2 API.

    The most restrictive API in this flow requires a scope of Manage Users or Manage All for the API credentials you use to generate the token.

  2. Prompt the user for their username or email address.

  3. Get the user ID, using the Get Users API.

    Pass the username or email address to the API to return the ID.

    Sample request:

    GET https://api.us.onelogin.com/api/2/users?username=ashley.akua

    Sample response:

    {
       "status":{
          "error":false,
          "code":200,
          "type":"success",
          "message":"Success"
       },
       "data":[
          {
             "activated_at":"2009-05-05T00:00:00.000Z",
             "created_at":"2009-05-05T03:18:08.338Z",
             "email":"ashley.akua@onelogin.com",
             "username":"aakua",
             "firstname":"Ashley",
             "group_id":123456,
             "id":121212,
             ...
          }
       ]
    }
  4. Get the list of devices registered to the user in OneLogin, with their device IDs, using the Get Enrolled Authentication Factors API.

  5. Trigger the MFA factor using the Activate a Factor API, and verify using Verify a Factor.

  6. Grant access when verification returns success.


Have a Question?

Have a how-to question? Seeing a weird error? Ask us about it on StackOverflow.

Found a bug? Submit a support ticket.

Have a product idea or request? Share it with us in our Ideas Portal.