Hey all,
I am working on a staging site that is password protected via basic authentication. I want to send API data on a form submission to the same site. If I disable the password protection on the site, the API request functions as expected, but when the site is protected, the request fails with a `401 Authorization Required` status. I have tried customizing the API request header with the following function:
/** | |
* REMOVE FROM PRODUCTION | |
* | |
* Set Basic Auth credentials for Formidable Forms | |
* | |
**/ | |
function ps_frm_api_request_header($arg_array, $args) | |
{ | |
$username = "USERNAME"; | |
$password = "PASSWORD"; | |
if ($args["url"] == "https://staging.example.com") { | |
// the full url where the request is being sent | |
$arg_array["headers"]["Authorization"] = | |
"Basic " . base64_encode($username . ":" . $password); | |
} | |
return $arg_array; | |
} | |
add_filter("frm_api_request_args", "ps_frm_api_request_header", 10, 2); |
However, the status of the API request still fails. Can anyone help me understand how to send API requests with a site password protected?
Please login or Register to submit your answer