Setup 2FA
curl --request POST \
--url https://olp-api.nipuntheekshana.com/v1/auth/2fa/setupimport requests
url = "https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup")
.asString();require 'uri'
require 'net/http'
url = URI("https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAuthentication
Setup 2FA
Generate a TOTP secret and QR code URI for setting up two-factor authentication
POST
/
v1
/
auth
/
2fa
/
setup
Setup 2FA
curl --request POST \
--url https://olp-api.nipuntheekshana.com/v1/auth/2fa/setupimport requests
url = "https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup")
.asString();require 'uri'
require 'net/http'
url = URI("https://olp-api.nipuntheekshana.com/v1/auth/2fa/setup")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyThis endpoint requires a valid Bearer token in the
Authorization header.otpauth:// URI that can be rendered as a QR code for authenticator apps like Google Authenticator or Authy.
After scanning the QR code, the merchant must call Verify 2FA with a valid code to complete the setup.
Example Response (200)
{
"secret": "JBSWY3DPEHPK3PXP",
"otpauthUrl": "otpauth://totp/OpenPay:admin@acmepay.com?secret=JBSWY3DPEHPK3PXP&issuer=OpenPay",
"qrCode": "data:image/png;base64,iVBORw0KGgo..."
}
The
secret is shown only once during setup. If the merchant loses it, they will need to disable and re-enable 2FA.Error Responses
409 Already Enabled
{
"error": {
"code": "CONFLICT",
"message": "Two-factor authentication is already enabled"
}
}