Skip to main content

Elixir Library

Installation

Install the SDK by adding LoginRadius to your mix.exs dependencies:

def deps do
[{:loginradius, "~> 1.0"}]
end

Then, run $ mix deps.get. A copy of the SDK can also be found on our Github.

Quickstart Guide

Before you can use any of the functions available in the library, some settings need to be configured first. To do this, add the following to your list of configurations in your config.exs file:

config :loginradius,
appname: <Your LoginRadius AppName>,
apikey: <Your ApiKey>,
apisecret: <Your ApiSecret>,
customapidomain: <Custom API Domain if any, "" if none>

The API key and secret can be obtained from the LoginRadius Admin Console. Details on retrieving your key and secret can be found here.

All API wrappers contained in the SDK will return either an ok or error tuple in the following format:

{<:ok | :error>, {<Status Code>, <Response Body>, <HTTPoison Response>}
(4XX-5XX responses will return :error)

Custom Domain

When initializing the SDK, optionally specify a custom domain. for more click here

 customapidomain: <Custom API Domain if any, "" if none>

SOTT Generation

Secured One Time Tokens can be generated locally using the provided helper function LoginRadius.Infrastructure.local_generate_sott/1, which takes in an integer representing lifetime in minutes as its only argument.

API

Authentication API

Auth Add Email

Adds additional emails to a user's account. More Info

Example:

access_token = "<Access Token>"
data = %{
"email" => "<Email>",
"type" => "Secondary"
}
verification_url = "<Verification URL>"
email_template = "<Template>"

response = access_token
|> LoginRadius.Authentication.add_email(data, verification_url, email_template)
Auth Forgot Password

Sends a reset password url to a specified account. More Info

Example:

reset_password_url = "<Reset URL>"
data = %{
"email" => "<Email>"
}
email_template = "<Template>"

response = reset_password_url
|> LoginRadius.Authentication.forgot_password(data, email_template)
Auth User Registration by Email

Creates a user in the database and sends a verification email to the user. More Info

Example:

data = %{
"Email" => [
%{
"Type" => "Primary",
"Value" => "<Email>"
}
],
"Password" => "<Password>"
}
verification_url = "<Verification URL>"
email_template = "<Template>"

response = data
|> LoginRadius.Authentication.user_registration_by_email(verification_url, email_template)
Auth Login by Email

Retrieves a copy of user data based on email. More Info

Example:

data = %{
"email" => "<Email>",
"password" => "<Password>"
}
verification_url = "<Verification URL>"
email_template = "<Template>"

response = data
|> LoginRadius.Authentication.login_by_email(verification_url, "", email_template)
Auth Login by Username

Retrieves a copy of user data based on username. More Info

Example:

data = %{
"username" => "<Username>",
"password" => "<Password>"
}
verification_url = "<Verification URL>"
email_template = "<Template>"

response = data
|> LoginRadius.Authentication.login_by_username(verification_url, "", email_template)
Auth Email Availability

Check if the specified email exists on your site. More Info

Example:

email = "<Email>"

response = email
|> LoginRadius.Authentication.check_email_availability()
Auth Username Availability

Check if the specified username exists on your site. More Info

Example:

username = "<Username>"

response = username
|> LoginRadius.Authentication.check_username_availability()
Auth Read Profiles by Token

Retrieves a copy of user data based on access token. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.Authentication.read_profiles_by_access_token()
Auth Privacy Policy Accept

Updates the privacy policy status in a user's profile based on access token. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.Authentication.privacy_policy_accept()
Auth Send Welcome Email

Sends a welcome email. More Info

Example:

access_token = "<Access Token>"
welcome_email_template = "<Template>"

response = access_token
|> LoginRadius.Authentication.send_welcome_email(welcome_email_template)
Auth Social Identity

Prevents RAAS profile of the second account from getting created (called before account linking API). More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.Authentication.social_identity()
Auth Validate Access Token

Validates access token, returns an error if token is invalid. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.Authentication.validate_access_token()
Auth Verify Email

Verifies the email of a user. More Info

Example:

verification_token = "<Verification Token>"
welcome_email_template = "<Template>"

response = verification_token
|> LoginRadius.Authentication.verify_email("", welcome_email_template)
Auth Delete Account

Delete an account based on delete token. More Info

Example:

delete_token = "<Delete Token>"

response = delete_token
|> LoginRadius.Authentication.delete_account()
Auth Invalidate Access Token

Invalidates an active access token. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.Authentication.invalidate_access_token()
Security Questions by Access Token

Retrieves the list of security questions that have been configured for an account by access token. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.Authentication.security_questions_by_access_token()
Security Questions by Email

Retrieves the list of security questions that have been configured for an account by email. More Info

Example:

email = "<Email>"

response = email
|> LoginRadius.Authentication.security_questions_by_email()
Security Questions by User Name

Retrieves the list of security questions that have been configured for an account by username. More Info

Example:

username = "<Username>"

response = username
|> LoginRadius.Authentication.security_questions_by_username()
Security Questions by Phone

Retrieves the list of security questions that have been configured for an account by phone ID. More Info

Example:

phone_id = "<Phone ID>"

response = phone_id
|> LoginRadius.Authentication.security_questions_by_phone()
Auth Verify Email by OTP

Verifies the email of a user when OTP Email verification flow is enabled. More Info

Example:

data = %{
"otp" => "<OTP>",
"email" => "<Email>"
}
welcome_email_template = "<Template>"

response = data
|> LoginRadius.Authentication.verify_email_by_otp("", welcome_email_template)
Auth Change Password

Changes an account's password based on previous password. More Info

Example:

access_token = "<Access Token>"
data = %{
"oldpassword" => "<Old Password>",
"newpassword" => "<New Password>"
}

response = access_token
|> LoginRadius.Authentication.change_password(data)

Links a social provider account with a specified account based on access token and social provider's user access token. More Info

Example:

access_token = "<Access Token>"
data = %{
"candidatetoken" => "<Provider Access Token>"
}

response = access_token
|> LoginRadius.Authentication.link_social_identities(data)
Auth Resend Email Verification

Resends a verification email to the user. More Info

Example:

data = %{
"email" => "<Email>"
}
verification_url = "<Verification URL>"
email_template = "<Template>"

response = data
|> LoginRadius.Authentication.resend_email_verification(verification_url, email_template)
Auth Reset Password by Reset Token

Sets a new password for a specified account using a reset token. More Info

Example:

data = %{
"resettoken" => "<Reset Token>",
"password" => "<New Password>",
"welcomeemailtemplate" => "<Template>",
"resetpasswordemailtemplate" => "<Template>"
}

response = data
|> LoginRadius.Authentication.reset_password_by_reset_token()
Auth Reset Password by OTP

Sets a new password for a specified account using a One Time Passcode. More Info

Example:

data = %{
"otp" => "<OTP>",
"email" => "<Email>",
"password" => "<Password>",
"welcomeemailtemplate" => "<Template>",
"resetpasswordemailtemplate" => "<Template>"
}

response = data
|> LoginRadius.Authentication.reset_password_by_otp()
Reset Password by Security Answer and Email (PUT)

Sets a new password for a specified account using a security answer and email. More Info

Example:

data = %{
"securityanswer" => %{
"<Security Question ID>" => "<Answer>"
},
"email" => "<Email>",
"password" => "<New Password>",
"resetpasswordemailtemplate" => "<Template>"
}

response = data
|> LoginRadius.Authentication.reset_password_by_security_answer_and_email()
Reset Password by Security Answer and Phone (PUT)

Sets a new password for a specified account using a security answer and phone. More Info

Example:

data = %{
"securityanswer" => %{
"<Security Question ID>" => "<Answer>"
},
"phone" => "<Phone ID>",
"password" => "<New Password>",
"resetpasswordemailtemplate" => "<Template>"
}

response = data
|> LoginRadius.Authentication.reset_password_by_security_answer_and_phone()
Reset Password by Security Answer and Username (PUT)

Sets a new password for a specified account using a security answer and username. More Info

Example:

data = %{
"securityanswer" => %{
"<Security Question ID>" => "<Answer>"
},
"username" => "<Username>",
"password" => "<New Password>",
"resetpasswordemailtemplate" => "<Template>"
}

response = data
|> LoginRadius.Authentication.reset_password_by_security_answer_and_username()
Auth Set or Change User Name

Sets or changes a username using an access token. More Info

Example:

access_token = "<Access Token>"
data = %{
"username" => "<Username>"
}

response = access_token
|> LoginRadius.Authentication.set_or_change_username(data)
Auth Update Profile by Token

Updates a user's profile using an access token. More Info

Example:

access_token = "<Access Token>"
data = %{
"Gender" => "<Gender>"
}
verification_url = "<Verification URL>"

response = access_token
|> LoginRadius.Authentication.update_profile_by_access_token(data, verification_url)
Auth Update Security Question by Access Token

Updates security questions using an access token. More Info

Example:

access_token = "<Access Token>"
data = %{
"securityquestionanswer" => %{
"<Security Question ID>" => "<Answer>"
}
}

response = access_token
|> LoginRadius.Authentication.update_security_questions_by_access_token(data)
Auth Delete Account with Email Confirmation

Deletes a user account using its access token. More Info

Example:

access_token = "<Access Token>"
email_template = "<Template>"

response = access_token
|> LoginRadius.Authentication.delete_account_with_email_confirmation("", email_template)
Auth Remove Email

Removes additional emails from a user's account. More Info

Example:

access_token = "<Access Token>"
data = %{
"email" => "<Email>"
}

response = access_token
|> LoginRadius.Authentication.remove_email(data)

Unlinks a social provider account with a specified account using its access token. More Info

Example:

access_token = "<Access Token>"
data = %{
"provider" => "<Provider>",
"providerid" => "<Provider ID>"
}

response = access_token
|> LoginRadius.Authentication.unlink_social_identities(data)

Account API

Account Create

Creates an account in LoginRadius Cloud Directory, bypassing the normal email verification process. More Info

Example:

data = %{
"Email" => [
%{
Type" => "Primary",
"Value" => "<Email>"
}
],
"Password" => "<Password>"
}

response = data
|> LoginRadius.Account.create()
Get Email Verification Token

Retrieves an Email Verification token. More Info

Example:

data = %{
"email" => "<Email>"
}

response = data
|> LoginRadius.Account.email_verification_token()
Get Forgot Password Token

Retrieves a Forgot Password token. More Info

Example:

data = %{
"email" => "<Email>"
}

response = data
|> LoginRadius.Account.forgot_password_token()
Account Identities by Email

Retrieves all identities associated with a specified email. More Info

Example:

email = "<Email>"

response = email
|> LoginRadius.Account.identities_by_email()
Account Impersonation

Retrieves a LoginRadius access token based on UID. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.Account.user_impersonation()
Account Password

Retrieves the hashed password of an account based on UID. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.Account.password()
Account Profiles by Email

Retrieves profile data based on email. More Info

Example:

email = "<Email>"

response = email
|> LoginRadius.Account.profiles_by_email()
Account Profiles by Username

Retrieves profile data based on username. More Info

Example:

username = "<Username>"

response = username
|> LoginRadius.Account.profiles_by_username()
Account Profiles by Phone ID

Retrieves profile data based on phone ID. More Info

Example:

phone_id = "<Phone ID>"

response = phone_id
|> LoginRadius.Account.profiles_by_phoneid()
Account Profiles by UID

Retrieves profile data based on UID. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.Account.profiles_by_uid()
Account Set Password

Sets the password of an account. More Info

Example:

uid = "<UID>"
data = %{
"password" => "<Password>"
}

response = uid
|> LoginRadius.Account.set_password(data)
Account Update

Updates the information of an existing account based on UID. More Info

Example:

uid = "<UID>"
data = %{
"Gender" => "<Gender>"
}

response = uid
|> LoginRadius.Account.update(data)
Account Update Security Question

Updates the security questions configuration of an existing account based on UID. More Info

Example:

uid = "<UID>"
data = %{
"securityquestionanswer" => %{
"<Security Question ID>" => "<Answer>"
}
}

response = uid
|> LoginRadius.Account.update_security_question_configuration(data)
Account Invalidate Verification Email

Invalidates the Email Verification status of an account. More Info

Example:

uid = "<UID>"
verification_url = "<Verification URL>"
email_template = "<Template>"

response = uid
|> LoginRadius.Account.invalidate_verification_status(verification_url, email_template)
Account Email Delete

Removes an email on an existing account based on UID. More Info

Example:

uid = "<UID>"
data = %{
"email" => "<Email>"
}

response = uid
|> LoginRadius.Account.email_delete(data)
Account Delete

Removes an existing user account based on UID. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.Account.delete()

Roles Management

Roles Create

Creates roles with permissions. More Info

Example:

data = %{
"roles" => [
%{
"name" => "<Role Name>",
"permissions" => %{
"<Permission Name>" => true,
"<Permission Name>" => true
}
}
]
}

response = data
|> LoginRadius.RolesManagement.roles_create()
Get Context

Retrieves the contexts which have been configured for a user and its associated roles and permissions. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.RolesManagement.get_contexts()
Roles List

Retrieves complete list of created roles with permissions of your app. More Info

Example:

response = LoginRadius.RolesManagement.roles_list()
Get Roles by UID

Retrieves all assigned roles of a particular user by uid. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.RolesManagement.roles_by_uid()
Add Permissions to Role

Adds permissions to a given role. More Info

Example:

role_name = "<Role Name>"
data = %{
"permissions" => [
"<Permission Name>",
"<Permission Name>"
]
}

response = role_name
|> LoginRadius.RolesManagement.add_permissions_to_role(data)
Assign Roles by UID

Assigns created roles to a user. More Info

Example:

uid = "<UID>"
data = %{
"Roles" => [
"<Role Name>"
]
}

response = uid
|> LoginRadius.RolesManagement.assign_roles_by_uid(data)
Upsert Context

Creates a context with a set of roles. More Info

Example:

uid = "<UID>"
data = %{
"rolecontext" => [
%{
"context" => "<Role Context Name>",
"roles" => [
"<Role Name>",
"<Role Name>"
],
"additionalpermissions" [
"<Additional Permission Name>",
"<Additional Permission Name>"
],
"expiration" => "<Expiration Date>"
}
]
}

response = uid
|> LoginRadius.RolesManagement.upsert_context(data)
Delete Role

Deletes a role given a role name. More Info

Example:

role_name = "<Role Name>"

response = role_name
|> LoginRadius.RolesManagement.delete_role()
Unassign Roles by UID

Unassigns roles from a user given uid. More Info

Example:

uid = "<UID>"
data = %{
"roles" => [
"<Role Name>"
]
}

response = uid
|> LoginRadius.RolesManagement.unassign_roles_by_uid(data)
Remove Permissions

Removes permissions from a role. More Info

Example:

role_name = "<Role Name>"
data = %{
"permissions" => [
"<Permission Name>"
]
}

response = role_name
|> LoginRadius.RolesManagement.remove_permissions(data)
Delete Context

Deletes a specified role context given UID and role context name. More Info

Example:

uid = "<UID>"
role_context_name = "<Role Context Name>"

response = uid
|> LoginRadius.RolesManagement.delete_role_context(role_context_name)
Delete Role from Context

Deletes a specified role from a context. More Info

Example:

uid = "<UID>"
role_context_name = "<Role Context Name>"
data = %{
"roles" => [
"<Role Name>"
]
}

response = uid
|> LoginRadius.RolesManagement.delete_role_from_context(role_context_name, data)
Delete Permissions from Context

Deletes additional permissions from context. More Info

Example:

uid = "<UID>"
role_context_name = "<Role Context Name>"
data = %{
"additionalpermissions" => [
"<Additional Permission Name>"
]
}

response = uid
|> LoginRadius.RolesManagement.delete_additional_permissions_from_context(role_context_name, data)

Social APIs

Post Message API

Posts messages to a user's contacts. This is part of the Friend Invite System. Used after the Contact API, and requires setting of permissions in LoginRadius Admin Console. Supported: Twitter, LinkedIn. More Info

Example:

access_token = "<Access Token>"
to = "<Recipient Social Provider ID>"
subject = "<Message Subject>"
message = "<Message>"

response = access_token
|> LoginRadius.SocialLogin.message_post(to, subject, message)
Get Trackable Status Stats

Updates the status on a user's wall. Supported: Facebook, Twitter, LinkedIn. More Info

Example:

access_token = "<Access Token>"
title = "<Title of Linked URL>"
url = "<URL to be shared in status>"
image_url = "<Image to be displayed in share>"
status = "<Status Body>"
caption = "<Message displayed below description>"
description = "<Description of displayed URL>"

response = access_token
|> LoginRadius.SocialLogin.status_posting_post(title, url, image_url, status, caption, description)
Access Token

Translates the request token returned during social provider authentication into an access token that can be used with LoginRadius API calls. More Info

Example:

request_token = "<Request Token>"

response = request_token
|> LoginRadius.SocialLogin.access_token()
Validate Access Token

Validates an access token, returns error if invalid. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.validate_access_token()
Invalidate Access Token

Invalidates an active access token. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.invalidate_access_token()
Album

Retrieves the photo albums associated with an access token. Supported: Facebook, Google, Live, Vkontakte. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.album()
Audio

Retrieves the audio files associated with an access token. Supported: Live, Vkontakte. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.audio()
Check-In

Retrieves the check in data associated with an access token. Supported: Facebook, Foursquare, Vkontakte. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.check_in()
Company

Retrieves a user's followed companies data associated with an access token. Supported: Facebook, LinkedIn. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.company()
Contact

Retrieves the contacts/friends/connections data associated with an access token. This is part of the LoginRadius Friend Invite System, and requires permissions to be set in the LoginRadius Admin Console. Supported: Facebook, Foursquare, Google, LinkedIn, Live, Twitter, Vkontakte, Yahoo. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.contact()
Event

Retrieves Event data associated with an access token. Supported: Facebook, Live. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.event()
Following

Retrieves Following user list associated with an access token. Supported: Twitter. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.following()
Group

Retrieves Group data associated with an access token. Supported: Facebook, Vkontakte. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.group()
Like

Retrieves Like data associated with an access token. Supported: Facebook. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.like()
Mention

Retrieves Mentions data associated with an access token. Supported: Twitter. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.mention()
Get Message API

Posts messages to a user's contacts. This is part of the Friend Invite System. Used after the Contact API, and requires setting of permissions in LoginRadius Admin Console. Identical to Message (POST). Supported: LinkedIn, Twitter. More Info

Example:

access_token = "<Access Token>"
to = "<Recipient Social Provider ID>"
subject = "<Message Subject>"
message = "<Message>"

response = access_token
|> LoginRadius.SocialLogin.message_get(to, subject, message)
Page

Retrieves page data associated with an access token. Supported: Facebook, LinkedIn. More Info

Example:

access_token = "<Access Token>"
page_name = "<Page Name>"

response = access_token
|> LoginRadius.SocialLogin.page(page_name)
Photo

Retrieves photo data associated with an access token. Supported: Facebook, Foursquare, Google, Live, Vkontakte. More Info

Example:

access_token = "<Access Token>"
album_id = "<Album ID>"

response = access_token
|> LoginRadius.SocialLogin.photo(album_id)
Post

Retrieves Post message data associated with an access token. Supported: Facebook. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.post()
Status Fetching

Retrieves status messages associated with an access token. Supported: Facebook, LinkedIn, Twitter, Vkontakte. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.status_fetching()
Status Posting

Updates the status on a user (associated with an access token)'s wall. Identical to Status Posting (POST). Supported: Facebook, Twitter, LinkedIn. More Info

Example:

access_token = "<Access Token>"
title = "<Title of Linked URL>"
url = "<URL to be shared in status>"
image_url = "<Image to be displayed in share>"
status = "<Status Body>"
caption = "<Message displayed below description>"
description = "<Description of displayed URL>"

response = access_token
|> LoginRadius.SocialLogin.status_posting_get(title, url, image_url, status, caption, description)
User Profile

Retrieves social profile data associated with an access token. Supported: All. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.user_profile()
Video

Retrieves video files data associated with an access token. Supported: Facebook, Google, Live, Vkontakte. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.SocialLogin.video()

Phone Authentication

Phone Login

Retrieves a copy of user data based on Phone ID. More Info

Example:

data = %{
"phone" => "<Phone ID>",
"password" => "<Password>",
"securityanswer" => %{
"<Security Question ID>" => "<Answer>"
}
}

response = data
|> LoginRadius.PhoneAuthentication.login()
Phone Forgot Password by OTP

Sends OTP to reset the account password. More Info

Example:

data = %{
"phone" => "<Phone ID>"
}
sms_template = "<Template>"

response = data
|> LoginRadius.PhoneAuthentication.forgot_password_by_otp(sms_template)
Phone Resend OTP

Resends a verification OTP to verify a user's phone number. User will receive a verification code that they will need to input. More Info

Example:

data = %{
"phone" => "<Phone ID>"
}
sms_template = "<Template>"

response = data
|> LoginRadius.PhoneAuthentication.resend_verification_otp(sms_template)
Phone Resend OTP by Token

Resends a verification OTP to verify a user's phone number in cases where an active token already exists. More Info

Example:

access_token = "<Access Token>"
data = %{
"phone" => "<Phone ID>"
}
sms_template = "<Template>"

response = data
|> LoginRadius.PhoneAuthentication.resend_verification_otp_by_access_token(data, sms_template)
Phone User Registration by SMS

Registers a new user into Cloud Directory and triggers the phone verification process. More Info

Example:

data = %{
"PhoneId" => "<Phone ID>",
"Email" => [
%{
"Type" => "Primary",
"Value" => "<Email>"
}
]
"Password" => "<Password>"
}
sms_template = "<Template>"

response = data
|> LoginRadius.PhoneAuthentication.user_registration_by_sms("", sms_template)
Phone Number Availability

Checks if the specified phone number already exists on your site. More Info

Example:

phone_id = "<Phone ID>"

response = phone_id
|> LoginRadius.PhoneAuthentication.phone_number_availability()
Phone Send OTP

Sends a One Time Passcode by verified phone ID. More Info

Example:

phone_id = "<Phone ID>"
sms_template = "<Template>"

response = phone_id
|> LoginRadius.PhoneAuthentication.send_one_time_passcode(sms_template)
Phone Login Using OTP

Verifies a login by One Time Passcode. More Info

Example:

data = %{
"phone" => "<Phone ID>",
"otp" => "<OTP>"
}

response = data
|> LoginRadius.PhoneAuthentication.login_using_one_time_passcode()
Phone Number Update

Updates a user's login phone number. More Info

Example:

access_token = "<Access Token>"
data = %{
"phone" => "<Phone ID>"
}

response = access_token
|> LoginRadius.PhoneAuthentication.phone_number_update(data)
Phone Reset Password by OTP

Resets a user's password using OTP. More Info

Example:

data = %{
"phone" => "<Phone ID>",
"otp" => "<OTP>",
"password" => "<Password>"
}

response = data
|> LoginRadius.PhoneAuthentication.reset_password_by_otp()
Phone Verify by OTP

This API is used to validate the verification code sent to verify a user's phone number. More Info

Example:

otp = "<OTP>"
data = %{
"phone" => "<Phone ID>"
}

response = otp
|> LoginRadius.PhoneAuthentication.verify_otp(data)
Phone Verify OTP by Access Token

Consumes the verification code sent to verify a user's phone number. For use in front-end where user has already logged in by passing user's access token. More Info

Example:

access_token = "<Access Token>"
otp = "<OTP>"

response = access_token
|> LoginRadius.PhoneAuthentication.verify_otp_by_access_token(otp)
Reset Phone ID Verification

Resets phone number verification of a user's account. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.PhoneAuthentication.reset_phone_id_verification()
Remove Phone ID by Access Token

Deletes the Phone ID on a user's account using access token. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.PhoneAuthentication.remove_phone_id_by_access_token()

Multi-Factor Authentication

MFA Email Login

Logs in by Email ID on a Multi-Factor Authentication enabled site. More Info

Example:

data = %{
"email" => "<Email ID>",
"password" => "<Password>"
}

response = data
|> LoginRadius.MultiFactorAuthentication.login_by_email()
MFA Username Login

Logs in by Username on a MFA enabled site. API wrapper is identical to email, except data object contains username instead of email. More Info

Example:

data = %{
"username" => "<Username>",
"password" => "<Password>"
}

response = data
|> LoginRadius.MultiFactorAuthentication.login_by_username()
MFA Phone Login

Logs in by Phone ID on a MFA enabled site. API wrapper is identical to email, except data object contains phone instead of email. More Info

Example:

data = %{
"phone" => "<Phone ID>",
"password" => "<Password>"
}

response = data
|> LoginRadius.MultiFactorAuthentication.login_by_phone()
MFA Validate Access Token

Configures MFA after login using access token. For use with MFA set to optional. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.MultiFactorAuthentication.validate_access_token()
MFA Backup Code by Access Token

Retrieves a set of backup codes using access token to allow user login on a site with MFA enabled in the event that the user does not have a secondary factor available. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.MultiFactorAuthentication.backup_codes_by_access_token()
MFA Reset Backup Code by Access Token

Resets the backup codes on a given account using access token. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.MultiFactorAuthentication.reset_backup_codes_by_access_token()
MFA Backup Code by UID

Retrieves a set of backup codes using UID. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.MultiFactorAuthentication.backup_codes_by_uid()
MFA Reset Backup Code by UID

Resets the backup codes on a given account using UID. More Info

Example:

uid = "<UID>"

response = uid
|> LoginRadius.MultiFactorAuthentication.reset_backup_codes_by_uid()
MFA Validate Backup Code

Validates the backup code provided by the user, returns an access token allowing user to login. More Info

Example:

second_factor_authentication_token = "<Second Factor Authentication Token>"
data = %{
backupcode => "<Backup Code>"
}

response = second_factor_authentication_token
|> LoginRadius.MultiFactorAuthentication.validate_backup_code(data)
MFA Validate OTP

Validates the One Time Passcode received via SMS for use with MFA. More Info

Example:

second_factor_authentication_token = "<Second Factor Authentication Token>"
data = %{
otp => "<OTP>"
}

response = second_factor_authentication_token
|> LoginRadius.MultiFactorAuthentication.validate_otp(data)
MFA Validate Google Auth Code

Validates google authenticator code for use with MFA. More Info

Example:

second_factor_authentication_token = "<Second Factor Authentication Token>"
data = %{
"googleauthenticatorcode" => "<Google Auth Code>"
}

response = second_factor_authentication_token
|> LoginRadius.MultiFactorAuthentication.validate_google_auth_code(data)
MFA Update Phone Number

Updates (if configured) the phone number used for MFA. API authenticates using the second factor authentication token. Sends a verification OTP to provided phone number. More Info

Example:

second_factor_authentication_token = "<Second Factor Authentication Token>"
data = %{
"phoneno2fa" => "<Multi Factor Phone Number>"
}
sms_template_2fa = "<Template>"

response = second_factor_authentication_token
|> LoginRadius.MultiFactorAuthentication.update_phone_number(data, sms_template_2fa)
MFA Update Phone Number by Access Token

Updates the MFA phone number by sending a verification OTP to the provided phone number. API authenticates using user's login access token. More Info

Example:

access_token = "<Access Token>"
data = %{
"phoneno2fa" => "<Multi Factor Phone Number>"
}
sms_template_2fa = "<Template>"

response = access_token
|> LoginRadius.MultiFactorAuthentication.update_phone_number_by_access_token(data, sms_template_2fa)
Update MFA by Access Token

Enables Multi Factor Authentication by access token upon user login. More Info

Example:

access_token = "<Access Token>"
data = %{
"googleauthenticatorcode" => "<Google Auth Code>"
}

response = access_token
|> LoginRadius.MultiFactorAuthentication.update_mfa_by_access_token(data)
Update MFA Setting

Enables Multi Factor Authentication by OTP upon user login. More Info

Example:

access_token = "<Access Token>"
data = %{
"otp" => "<OTP>"
}

response = access_token
|> LoginRadius.MultiFactorAuthentication.update_mfa_setting(data)
MFA Reset Google Authenticator by Access Token

Resets the Google Authenticator configurations on a given account using user's access token. More Info

Example:

access_token = "<Access Token>"
data = %{
"googleauthenticator" => true
}

response = access_token
|> LoginRadius.MultiFactorAuthentication.reset_google_authenticator_by_access_token(data)
MFA Reset SMS Authenticator by Access Token

Resets the SMS Authenticator configurations on a given account using user's access token. Identical to Reset Google Authenticator by Access Token except data object has key otpauthenticator instead of googleauthenticator. More Info

Example:

access_token = "<Access Token>"
data = %{
"otpauthenticator" => true
}

response = access_token
|> LoginRadius.MultiFactorAuthentication.reset_sms_authenticator_by_access_token(data)
MFA Reset Google Authenticator by UID

Resets the Google Authenticator configurations on a given account using user's UID. More Info

Example:

uid = "<UID>"
data = %{
"googleauthenticator" => true
}

response = uid
|> LoginRadius.MultiFactorAuthentication.reset_google_authenticator_by_uid(data)
MFA Reset SMS Authenticator by UID

Resets the SMS Authenticator configurations on a given account using user's UID. Identical to Reset Google Authenticator by UID except data object has key otpauthenticator instead of googleauthenticator. More Info

Example:

uid = "<UID>"
data = %{
"otpauthenticator" => true
}

response = uid
|> LoginRadius.MultiFactorAuthentication.reset_sms_authenticator_by_uid(data)

Passwordless Login

Passwordless Login by Email

Sends a Passwordless Login verification link to provided email. More Info

Example:

email = "<Email>"
passwordless_login_template = "<Template>"
verification_url = "<Verification URL>"

response = email
|> LoginRadius.PasswordlessLogin.login_by_email(passwordless_login_template, verification_url)
Passwordless Login by Username

Sends a Passwordless Login verification link to provided username. More Info

Example:

username = "<Username>"
passwordless_login_template = "<Template>"
verification_url = "<Verification URL>"

response = username
|> LoginRadius.PasswordlessLogin.login_by_email(passwordless_login_template, verification_url)
Passwordless Login Verification

Verifies a Passwordless Login verification link. More Info

Example:

verification_token = "<Verification Token>"
welcome_email_template = "<Template>"

response = verification_token
|> LoginRadius.PasswordlessLogin.login_verification(welcome_email_template)

Smart Login

Smart Login By Email

Sends a Smart Login link to a user's email using specified email. More Info

Example:

email = "<Email>"
client_guid = "<Client GUID>"
smart_login_email_template = "<Template>"
welcome_email_template = "<Template>"
redirect_url = "<Redirect URL>"

response = email
|> LoginRadius.SmartLogin.login_by_email(client_guid, smart_login_email_template, welcome_email_template, redirect_url)
Smart Login by Username

Sends a Smart Login link to a user's email using specified username. More Info

Example:

username = "<Username>"
client_guid = "<Client GUID>"
smart_login_email_template = "<Template>"
welcome_email_template = "<Template>"
redirect_url = "<Redirect URL>"

response = username
|> LoginRadius.SmartLogin.login_by_email(client_guid, smart_login_email_template, welcome_email_template, redirect_url)
Smart Login Ping

Checks if the Smart Login link has been clicked or not. More Info

Example:

client_guid = "<Client GUID>"

response = client_guid
|> LoginRadius.SmartLogin.ping()
Smart Login Verify Token

Verifies the provided token for Smart Login. More Info

Example:

verification_token = "<Verification Token>"
welcome_email_template = "<Template>"

response = verification_token
|> LoginRadius.SmartLogin.verify_token(welcome_email_template)

One Touch Login

One Touch Login by Email

Sends a link to a specified email for frictionless login. More Info

Example:

email = "<Email>"
client_guid = "<Client GUID>"
name = "<Name of User>"
redirect_url = "<Redirect URL>"
one_touch_login_email_template = "<Template>"
welcome_email_template = "<Template>"

response = email
|> LoginRadius.OneTouchLogin.login_by_email(client_guid, name, redirect_url, one_touch_login_email_template, welcome_email_template)
One Touch Login by Phone

Sends a One Time Password to a given phone number for a frictionless login. More Info

Example:

phone_id = "<Phone ID>"
name = "<Name of User>"
sms_template = "<Template>"

response = phone_id
|> LoginRadius.OneTouchLogin.login_by_phone(name, sms_template)
One Touch Email Verification

Verifies the provided token for One Touch Login by email. More Info

Example:

verification_token = "<Verification Token>"
welcome_email_template = "<Template>"

response = verification_token
|> LoginRadius.OneTouchLogin.verify_otp_by_email(welcome_email_template)
One Touch OTP Verification

Verifies the One Time Passcode for One Touch Login. More Info

Example:

otp = "<OTP>"
data = %{
"phone" => "<Phone ID>"
}
sms_template = "<Template>"

response = otp
|> LoginRadius.OneTouchLogin.verify_otp(data, sms_template)

Custom Object Management

Create Custom Object by UID

Writes data to a custom object for a specified account by uid. More Info

Example:

uid = "<UID>"
object_name = "<Object Name>"
data = %{
"<Custom Data Key>" => "<Custom Data Value>",
"<Custom Data Key>" => "<Custom Data Value>"
}

response = uid
|> LoginRadius.CustomObjectManagement.create_by_uid(object_name, data)
Create Custom Object by Token

Writes data to a custom object for a specified account by access token. More Info

Example:

access_token = "<Access Token>"
object_name = "<Object Name>"
data = %{
"<Custom Data Key>" => "<Custom Data Value>",
"<Custom Data Key>" => "<Custom Data Value>"
}

response = access_token
|> LoginRadius.CustomObjectManagement.create_by_access_token(object_name, data)
Custom Object by ObjectRecordId and UID

Retrieves Custom Object data for a specified account by object name, id, and account uid. More Info

Example:

uid = "<UID>"
object_record_id = "<Object Record ID>"
object_name = "<Object Name>"

response = uid
|> LoginRadius.CustomObjectManagement.get_by_objectrecordid_and_uid(object_record_id, object_name)
Custom Object by ObjectRecordId and Token

Retrieves Custom Object data for a specified account by object name, id, and access token. More Info

Example:

access_token = "<Access Token>"
object_record_id = "<Object Record ID>"
object_name = "<Object Name>"

response = access_token
|> LoginRadius.CustomObjectManagement.get_by_objectrecordid_and_access_token(object_record_id, object_name)
Custom Object by Token

Retrieves Custom Object data for a specified account by object name and access token. More Info

Example:

access_token = "<Access Token>"
object_name = "<Object Name>"

response = access_token
|> LoginRadius.CustomObjectManagement.get_by_access_token(object_name)
Custom Object by UID

Retrieves Custom Object data for a specified account by object name and account uid. More Info

Example:

uid = "<UID>"
object_name = "<Object Name>"

response = uid
|> LoginRadius.CustomObjectManagement.get_by_uid(object_name)
Custom Object Update by ObjectRecordId and UID

Updates Custom Object data for a specified account by object name, id, and account uid. If updatetype = replace, object will be replaced with new object. If updatetype = partialreplace, new object will be upserted(merged). More Info

Example:

uid = "<UID>"
object_record_id = "<Object Record ID>"
object_name = "<Object Name>"
update_type = "<Update Type>"
data = %{
"<Custom Data Key>" => "<Custom Data Value>"
}

response = uid
|> LoginRadius.CustomObjectManagement.update_by_objectrecordid_and_uid(object_record_id, object_name, update_type, data)
Custom Object Update by ObjectRecordId and Token

This API is used to update the specified custom object data of the specified account. More Info

Example:

access_token = "<Access Token>"
object_record_id = "<Object Record ID>"
object_name = "<Object Name>"
update_type = "<Update Type>"
data = %{
"<Custom Data Key>" => "<Custom Data Value>"
}

response = access_token
|> LoginRadius.CustomObjectManagement.update_by_objectrecordid_and_access_token(object_record_id, object_name, update_type, data)
Custom Object Delete by ObjectRecordId and UID

Deletes Custom Object data from a specified account by object name, id, and account uid. More Info

Example:

uid = "<UID>"
object_record_id = "<Object Record ID>"
object_name = "<Object Name>"

response = uid
|> LoginRadius.CustomObjectManagement.delete_by_objectrecordid_and_uid(object_record_id, object_name)
Custom Object Delete by ObjectRecordId and Access Token

Deletes Custom Object data from a specified account by object name, id, and access token. More Info

Example:

access_token = "<Access Token>"
object_record_id = "<Object Record ID>"
object_name = "<Object Name>"

response = access_token
|> LoginRadius.CustomObjectManagement.delete_by_objectrecordid_and_access_token(object_record_id, object_name)

Custom Registration Data

Add Registration Data

Adds data to your custom DropDownList configured for user registration. More Info

Example:

data = %{
"Data" => [
%{
"type" => "<Type of Datasource>",
"key" => "<Text to Display>",
"value" => "<Value>",
"parentid" => "<ID of Parent Member>",
"code" => "<Validation Code>",
"isactive" => #true/false
}
]
}

response = data
|> LoginRadius.CustomRegistrationData.add_registration_data()
Validate Code

Adds data to your custom DropDownList configured for user registration. More Info

Example:

data = %{
"recordid" => "<Record ID>",
"code" => "<Validation Code>"
}

response = data
|> LoginRadius.CustomRegistrationData.validate_code()
Get Registration Data

Retrieves dropdown data. More Info

Example:

type = "<Type of Datasource>"
parent_id = "<ID of Parent Member>"
skip = "<Records to Skip>"
limit = "<Records to Retrieve>"

response = type
|> LoginRadius.CustomRegistrationData.get_registration_data(parent_id, skip, limit)
Auth Get Registration Data

Retrieves dropdown data. More Info

Example:

type = "<Type of Datasource>"
parent_id = "<ID of Parent Member>"
skip = "<Records to Skip>"
limit = "<Records to Retrieve>"

response = type
|> LoginRadius.CustomRegistrationData.auth_get_registration_data(parent_id, skip, limit)
Update Registration Data

Updates a member of configured DropDownList. More Info

Example:

record_id = "<Record ID>"
data = %{
"IsActive" => #true/false,
"Type" => "<Type of Datasource>",
"Key" => "<Text to Display>",
"Value" => "<Value>",
"ParentId" => "<ID of Parent Member>",
"Code" => "<Validation Code>"
}

response = record_id
|> LoginRadius.CustomRegistrationData.update_registration_data(data)
Delete Registration Data

Deletes a member of configured DropDownList. More Info

Example:

record_id = "<Record ID>"

response = record_id
|> LoginRadius.CustomRegistrationData.delete_registration_data()

Configuration/Infrastructure

Get Configurations

Gets set configurations from the LoginRadius Admin Console for a particular site from apikey. More Info

Example:

response = LoginRadius.Configuration.get_configurations()
Get Server Time

Queries for basic server information. Time difference is used to generate values for SOTT generation. More Info

Example:

time_difference = "<Time Difference>"

response = time_difference
|> LoginRadius.Infrastructure.get_server_time()
Generate SOTT Token

Generates a Secured One Time Token. More Info

Example:

validity_length = "<Valid time for SOTT>"

response = validity_length
|> LoginRadius.Infrastructure.generate_sott()
Generate Local SOTT Token

Generates a Secured One Time Token locally. Returns a String.t().

Example:

validity_length = "<Valid time for SOTT>"

sott = validity_length
|> LoginRadius.Infrastructure.local_generate_sott()

Token Management

Access Token via Facebook Token

Retrieves a LoginRadius access token by sending Facebook's access token. More Info

Example:

fb_access_token = "<Access Token from Facebook>"

response = fb_access_token
|> LoginRadius.TokenManagement.access_token_via_facebook_token()
Access Token via Twitter Token

Retrieves a LoginRadius access token by sending Twitter's access token and token secret. More Info

Example:

tw_access_token = "<Access Token from Twitter>"
tw_token_secret = "<Token Secret from Twitter>"

response = tw_access_token
|> LoginRadius.TokenManagement.access_token_via_twitter_token(tw_token_secret)
Access Token via Vkontakte Token

Retrieves a LoginRadius access token by sending Vkontakte's access token. More Info

Example:

vk_access_token = "<Access Token from Vkontakte>"sss

response = vk_access_token
|> LoginRadius.TokenManagement.access_token_via_vkontakte_token()
Refresh User Profile

Retrieves the latest updated social profile data after authentication. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.TokenManagement.refresh_user_profile()
Refresh Token

Refreshes the LoginRadius access token after authentication. Also refreshes the provider access token if available. Supported Providers: Facebook, Yahoo, Google, Twitter, Linkedin. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.TokenManagement.refresh_access_token()
Get Active Session Details

Retrieves all active sessions by an access token. Supported Providers: Facebook, Yahoo, Google, Twitter, Linkedin. More Info

Example:

access_token = "<Access Token>"

response = access_token
|> LoginRadius.TokenManagement.get_active_session_details()

Webhooks

Webhook Subscribe

Subscribes a Webhook on your LoginRadius site. More Info

Example:

data = %{
"targeturl" => "<Target URL>",
"event" => "<Event>"
}

response = data
|> LoginRadius.Webhooks.subscribe()
Webhook Test

Tests subscribed Webhooks. More Info

Example:

response = LoginRadius.Webhooks.test()
Webhook Subscribed URLs

Retrieves all subscribed URLs for a particular event. More Info

Example:

event = "<Event>"

response = event
|> LoginRadius.Webhooks.get_subscribed_urls()
Webhook Unsubscribe

Unsubscribes a Webhook configured on your LoginRadius site. More Info

Example:

data = %{
"targeturl" => "<Target URL>",
"event" => "<Event>"
}

response = data
|> LoginRadius.Webhooks.unsubscribe()

Tests

A test suite is included and available for use in the Github repository. To run these tests, download the project and navigate to its root directory. Fill out your credential information in config/config.exs. Use $ mix test to run the test suite. To test Social APIs, ensure that the social provider tokens are filled out in the test/loginradius_test.exs file. To test Custom Object Management APIs, ensure that the test custom object name is filled out in the same file.

To test Multi Factor Authentication APIs, ensure that MFA is set to enabled on your LoginRadius Admin Console, and use $ mix test --only mfa to run the suite.

Demo

A simple demo web application with an Elixir server backend (using the Elixir SDK) is available here. The following features are included:

  • Traditional Email Login
  • Multi-Factor Email Login
  • Passwordless Login
  • Social Login
  • Registration
  • Email Verification
  • Forgot Password
  • Reset Password
  • Change Password
  • Set Password
  • Update Account
  • Multi-Factor Configuration
  • Account Linking
  • Custom Object Management
  • Roles Management

Configuration

Install Elixir from their site here.

Back-end
  1. Fill your app name, API key and secret in the config/config.exs file in the back-end demo directory.
  2. Run $ mix deps.get to fetch any required dependencies.
  3. Start the server with $ mix phx.server.
Front-end
  1. Put the front-end project into the root directory of your server.
  2. Fill your API key, app name and an SOTT in the js/options.js file in the front-end demo directory.
  3. Ensure the Elixir server is running in the background.

Reference Manual

Find the Elixir hex.pm reference manual here.