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.
For 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.
Resource URL
https://<subdomain>/api/2/mfa/users/<user_id>/registrations
Header Parameter
Authorization required string | Set to Set 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 the |
Resource Parameter
user_id required integer |
Set to the If you don’t know the user’s |
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 |
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 = Factors such as |
redirect_to string |
Optional. Only applies to Email MagicLink factor. Redirects MagicLink success page to specified URL after 2 seconds. Email must already be configured by the user. |
custom_message string |
Optional. Only applies to SMS factor. A message template that will be sent via SMS. Max length of the message after template items are inserted is 160 characters including the OTP code. SMS must already be configured by the user. The following template variables can be included in the message.
|
Request Body
{
"factor_id": 58959,
"display_name": "OneLogin SMS"
}
Sample Responses
OneLogin SMS
- 201 Created
- 401 Unauthorized
[
{
"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
- 200 OK
- 401 Unauthorized
[
{
"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
- 200 OK
- 401 Unauthorized
[
{
"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
- 200 OK
- 401 Unauthorized
[
{
"id": "83bf1253-2011-4f75-aa67-c100330156f5",
"status": "pending",
"auth_factor_name": "OneLogin Email",
"type_display_name": "OneLogin Email",
"user_display_name": "OneLogin Email",
"expires_at": "2020-07-21T18:14:09Z"
}
]
{
"statusCode": 401,
"name": "InvalidCredentials",
"message": "Please provide valid credentials"
}
Authenticator
- 200 OK
- 401 Unauthorized
[
{
"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
|
|
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
- 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 Code
cURL
Replace sample values indicated by < >
with your actual values.
curl 'https://<subdomain>/api/2/mfa/users/<user_id>/registrations' \
-X POST \
-H "Authorization: bearer: <access_token>" \
-H "Content-Type: application/json" \
-d '{
"factor_id": 16282,
"display_name": "Rich's Phone"
}'
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.