Generating OTP

pradeep49
Kilo Contributor

Hi,

How to generate OTP in Servicenow through API... Please suggest me how to achieve it.

Thanks in advance.

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

There is a free Store App "One-time Password Generator" (https://store.servicenow.com/sn_appstore_store.do#!/store/application/5c95cd8f870e1010926420eac5cb0b...) which would do the job but unfortunately there is no documentation available.

Kind regards
Maik

@pradeep49 I had a look at the app Maik mentioned as I needed this for our implementation.

After installation you get an Script Include "sn_otp_support_uti.OtpSupportUtil" which can be used to create, validate and invalidate and access token for a particular record.

 

Example

// Generates an OTP Code for the current user record which is valid for 10 minutes
// Function returns the GlideRecord of the Access Token (Table: sn_otp_support_util_access_token)
new sn_otp_support_uti.OtpSupportUtil().createAccessToken('sys_user', gs.getUserID(), 10);

// Validates the token until max count (Property: sn_otp_support_util.max_otp_validation_failures)
new sn_otp_support_uti.OtpSupportUtil().isValidAccessToken('sys_user', gs.getUserID(), 'myTokenValue');

 

Unfortunately the API only provides the token generation/validation and some logs. The rest is up to you for the implementation (sending the token, UI for validation etc).