See api-docs Menu

Enroll an Authentication Factor


Use this API to initiate enrollment for user with a given authentication factor.

If the authentication factor requires confirmation to complete, then the device will have an status of pending otherwise it will have a status of accepted (corresponding to devices that are either pending confirmation or not)

To change the state of the device to be accepted, the registration id, and the `otp` would need to be sent to the Verify a Factor endpoint.

Specifically to OneLogin Voice the end-user must type the OTP code into the phone, and verification can be complted using this Verify a Factor endpoint.

The API supports enrollment of support for SMS, Voice, Email, Google Authenticator, and OneLogin Protect. Other factors can be enrolled manually by the user.

Early Preview

This API is in early preview and may be subject to change. Please refer to our V1 API for current production use.

Resource URL

https://<api-domain>/api/2/users/<user_id>/registrations

Header Parameter

Authorization

required

string

Set to bearer:<access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using any one of the following scopes: Manage users or Manage All.

Resource Parameter

user_id

required

integer

Set to the id of the user.

If you don’t know the user’s id, use the Get Users API call to return all users and their id values.

Request Parameters

factor_id

required

integer

The identifier of the factor to enroll the user with.

See Get Available Factors for a list of possible id values.

display_name

required

string

A name for the users device

expires_in

string

Defaults to 120. Valid values are: 120-900 seconds.

verified

boolean

Defaults to false. The following factors support verified = true as part of the initial registration request: OneLogin SMS, OneLogin Voice, OneLogin Email. When using verified = true it is critical that the supported factors have pre-verified values, most likely imported from an existing directory or by the users themselvdes.

Factors such as Authenticator and OneLogin Protect do not support verification = true as the user interaction is required to verify the factor.

Request Body

{
    "factor_id": "58959",
    "display_name": "OneLogin SMS"
}

Sample Responses

OneLogin SMS

[
  {
    "id": "a89ea78d-59fd-4ec2-8b62-b6796ff9e7b3",
    "status": "pending",
    "auth_factor_name": "SMS",
    "type_display_name": "OneLogin SMS",
    "user_display_name": "OneLogin SMS",
    "expires_at": "2020-07-21T17:27:34Z"
  }
]
  
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

OneLogin Protect

[
  {
    "id": "36c6cf4c-a315-46ce-81f9-a91a475488cf",
    "status": "pending",
    "auth_factor_name": "OneLogin",
    "type_display_name": "OneLogin Protect",
    "user_display_name": "OneLogin Protect",
    "factor_data": {
        "verification_token": "01-1912451",
        "totp_url": "otpauth://totp/bsimons:brandon.simons%2Badmin%40onelogin.com?secret=01-1912451"
    }
  ]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

OneLogin Voice

[
  {
      "id": "500b41d2-4c6d-4fb3-928b-44d8c0afa19b",
      "status": "pending",
      "auth_factor_name": "OneLogin Voice",
      "type_display_name": "OneLogin Voice",
      "user_display_name": "OneLogin Voice",
      "expires_at": "2020-07-21T18:11:54Z",
      "factor_data": {
          "verification_token": "144613"
      }
  }
]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

OneLogin Email

[
  {
      "id": "83bf1253-2011-4f75-aa67-c100330156f5",
      "status": "pending",
      "auth_factor_name": "OneLogin Email",
      "type_display_name": "OneLogin Email",
      "user_display_name": "OneLogin Voice",
      "expires_at": "2020-07-21T18:14:09Z"
  }
]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

Authenticator

[
  {
      "id": "922f6f3b-424a-43eb-aafb-3f45596f0fc5",
      "status": "pending",
      "auth_factor_name": "Google Authenticator",
      "type_display_name": "Authenticator",
      "user_display_name": "Authenticator",
      "factor_data": {
          "verification_token": "d5j3sck2s7hh3nxzkxj5p7nt5yk2a75d",
          "totp_url": "otpauth://totp/brandon.simons%2Badmin%40onelogin.com?secret=d5j3sck2s7hh3nxzkxj5p7nt5yk2a75d&issuer=bsimons"
      }
  }
  ]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

Response Elements

status

accepted : factor has been verified. pending: registered but has not been verified.

default True = is user’s default MFA device for OneLogin.
expires_at A short lived token that is required to Verify the Factor. This token expires based on the expires_in parameter passed in.
auth_factor_name "Official" authentication factor name, as it appears to administrators in OneLogin.
type_display_name Authentication factor display name as it appears to users upon initial registration, as defined by admins at Settings > Authentication Factors.
user_display_name Authentication factor display name assigned by users when they enroll the device.
id MFA device identifier.
factor_data Array of factor specific properties. For example, the token or totp code for OneLogin Protect.
verification_token The token which can be used to verify the factor registration.
totp_url OTP Url that can be leveraged for any authenticator that supports the key uri format. Url can be used with client libraries to display QR Code for streamlined end-user registration.

Postman Collection

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

Download for the MFA API

Sample Code

cURL

Replace sample values indicated by < > with your actual values.

curl 'https://<api-domain>/api/2/mfa/users/<user_id>/registrations' \
-X POST \
-H "Authorization: bearer: <access_token>" \
-d '{
  "factor_id": 16282,
  "display_name":  "Rich's Phone"
}'

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

    fully re-authenticate to OneLogin (including MFA) every 60 minutes as the AWS temporary credentials expire. I think that won't fly - our users are accustomed to permanent API credentials tied to a … 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 …

  • 2
    Votes
    1
    Answers

    Q: Implement custom connector to in-house applications

    Asked Dec 05 2016

    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. So I was suggested to … I am trying to figure out how custom connectors work or if it's the correct solution. Basically the company I work at wants to implement a "login using OneLogin" to our in-house applications and we …

  • 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 … because of the short validity. 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

    While being able to generate a SAML assertion for any user (without the need for MFA and a user/pass) seems like a good workaround, this is unfortunately fraught with security perils. An API that … hours. 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 …

  • 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 MFAAPI url for Duo. The base64 encoded elements are the user's email, what I'm assuming is the user's Duo ID, and a number that I'm unsure about since it changes with every request. I'm assuming this …

Loading...