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

Run In Postman

    Clicking Run in Postman button navigates to the page where you can fork the collection to your workspace. Forking the collection into your workspace will enable you to contribute to the source collection using pull requests. You can also view the collection in a public workspace if you like and even import a copy of the collection using the links present on the screen.

Sample Workflows

Silent MFA enrollment

This sample shows how you can register a factor for a user without requiring their input or verification. The workflow is similar for both email and SMS enrollment.

<

ol>

  • 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.

  • 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. Get the user ID, using the Get Users API.

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

    4. 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://<subdomain>.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,
               ...
            }
         ]
      }
    5. Get the list of devices registered to the user in OneLogin, with their device IDs, using the Get Enrolled Authentication Factors API.

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

    7. Grant access when verification returns success.


    Have a Question?

    Found a problem or a bug? Submit a support ticket.

    Looking for walkthroughs or how-to guides on OneLogin's user and admin features? Check out the documentation in our Knowledge Base.

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