OTP Status and Validation
2 min
- In order to send otpValid request, otpStatus must be called first.
- otpStatus method returns true, otpValid should be sent. otpStatus asks whether otp is active or inactive for the user, if otp is active this method generate valid OTP value then returned true response
otpStatus
otpStatus
POST
https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus
csharp
var client = new RestClient("https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Cookie", "NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a");
request.AddParameter("username", "batuhan.tests");
request.AddParameter("endUserIp", "1.2.3.4");
request.AddParameter("applicationName", "BatuhanBilginDeneme");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);curl
curl --location --request POST 'https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a' \
--data-urlencode 'username=batuhan.test' \
--data-urlencode 'endUserIp=1.2.3.4' \
--data-urlencode 'applicationName=BatuhanBilginDeneme'javascript
var settings = {
"url": "https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a"
},
"data": {
"username": "batuhan.tests",
"endUserIp": "1.2.3.4",
"applicationName": "BatuhanBilginDeneme"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});200
true --> Comment: user otp status is opened
false --> Comment: user otp status is closed
otpValid
otpValid
POST
https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid
csharp
var client = new RestClient("https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Cookie", "NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a");
request.AddParameter("username", "batuhan.test");
request.AddParameter("token", "489375");
request.AddParameter("applicationName", "BatuhanBilginDeneme");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);curl
curl --location --request POST 'https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a' \
--data-urlencode 'username=batuhan.test' \
--data-urlencode 'token=489375' \
--data-urlencode 'applicationName=BatuhanBilginDeneme'javascript
var settings = {
"url": "https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a"
},
"data": {
"username": "batuhan.test",
"token": "296242",
"applicationName": "BatuhanBilginDeneme"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});200
Comment: otp is valid403
<!doctype html> --> Comment: otp is not valid
<html lang="en">
<head>
<title>HTTP Status 403 – Forbidden</title>
<style type="text/css">
body {
font-family: Tahoma, Arial, sans-serif;
}
h1,
h2,
h3,
b {
color: white;
background-color: #525D76;
}
h1 {
font-size: 22px;
}
h2 {
font-size: 16px;
}
h3 {
font-size: 14px;
}
p {
font-size: 12px;
}
a {
color: black;
}
.line {
height: 1px;
background-color: #525D76;
border: none;
}
</style>
</head>
<body>
<h1>HTTP Status 403 – Forbidden</h1>
</body>
</html>