oath\_authenticate\_usersfile(3) liboath oath\_authenticate\_usersfile(3)

# [NAME](#NAME)

oath\_authenticate\_usersfile - API function

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;oath.h&gt;**

**int oath\_authenticate\_usersfile(const char * usersfile, const char * username, const char * otp, size\_t window, const char * passwd, time\_t * last\_otp);**

# [ARGUMENTS](#ARGUMENTS)

[const char * usersfile](#const)

string with user credential filename, in UsersFile format

[const char * username](#const~2)

string with name of user

[const char * otp](#const~3)

string with one-time password to authenticate

[size\_t window](#size_t)

how many past/future OTPs to search

[const char * passwd](#const~4)

string with password, or NULL to disable password checking

[time\_t * last\_otp](#time_t)

output variable holding last successful authentication

# [DESCRIPTION](#DESCRIPTION)

Authenticate user named *username* with the one-time password *otp* and (optional) password *passwd*. Credentials are read (and updated) from a text file named *usersfile*.

Note that for TOTP the usersfile will only record the last OTP and use that to make sure more recent OTPs have not been seen yet when validating a new OTP. That logics relies on using the same search window for the same user.

# [RETURNS](#RETURNS)

On successful validation, **OATH\_OK** is returned. If the supplied *otp* is the same as the last successfully authenticated one-time password, **OATH\_REPLAYED\_OTP** is returned and the timestamp of the last authentication is returned in *last\_otp*. If the one-time password is not found in the indicated search window, **OATH\_INVALID\_OTP** is returned. Otherwise, an error code is returned.

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;oath-toolkit-help@nongnu.org&gt;. liboath home page: https://www.nongnu.org/oath-toolkit/ General help using GNU software: http://www.gnu.org/gethelp/

# [COPYRIGHT](#COPYRIGHT)

Copyright © 2009-2020 Simon Josefsson.  
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.

2.6.12-dirty liboath

---

Document: oath_authenticate_usersfile(3) from oath-toolkit 2.6.12-r13 (Chainguard OS)
Source: https://gitlab.com/oath-toolkit/oath-toolkit.git
