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.

Early Preview

These APIs are in early preview and may be subject to change. Please refer to our V1 APIs for current production use.

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.

StackOverflow discussions about "[onelogin] mfa api"

  • 9
    Votes
    2
    Answers

    Q: AWS API credentials with OneLogin SAML and MFA

    Asked Oct 30 2016

    We want to allow our users to retrieve a set of temporary CLI credentials for a given AWS role by signing in to OneLogin with password and MFA. … We have a working solution, but it requires the user to fully re-authenticate to OneLogin (including MFA) every 60 minutes as the AWS temporary credentials expire. …

  • 2
    Votes
    1
    Answers

    Q: Implement custom connector to in-house applications

    Asked Dec 05 2016

    Basically the company I work at wants to implement a "login using OneLogin" to our in-house applications and we have MFA enabled. … I tried the API route but it requires the user to enter the MFA code every time they want to log in, which is great for security but users want simple solution. …

  • 1
    Votes
    1
    Answers

    Q: Getting a SAML assertion after creating a session via API

    Asked Apr 04 2017

    Related to Accessing Third Party Apps After Creating A Session Via API Token and to AWS API credentials with OneLogin SAML and MFA Since AWS assumeRoleWithSAML temporary security credentials are only … It's totally odd to the web base OneLogin usage, where he is logged in once for the whole day or even week (depending on the policy). I know how to get a session via API. …

  • 1
    Votes

    A: Getting a SAML assertion after creating a session via API

    Answered Apr 05 2017

    The "assume user" privilege is locked down pretty tightly in OneLogin, and is not the sort of thing that's given out lightly. … This wouldn't allow for MFA on an app policy, but we are building out the ability to request and verify MFA via API (coming soon) so you could implement MFA in your app (independent of any app policy) …

  • 1
    Votes
    2
    Answers

    Q: Onelogin API - Verify Factor for SAML assertion when using Duo

    Asked Oct 11 2017

    I've been developing an application that hits the api/1/saml_assertion, https://developers.onelogin.com/api-docs/1/saml-assertions/generate-saml-assertion , endpoint of OneLogin with Duo as my MFA. … duo_sig_request looks like this: 'duo_sig_request': 'TX|<base64 encoded elements>|<what looks like a sha1 hash>:APP|<base64 encoded elements>|<what looks like a sha1 hash>' duo_api_hostname is just the API …

Loading...