I am copy pasting the password though.
I am encountering an issue with using Application Passwords for REST API integration on a WordPress site hosted with Afrihost. My goal is to programmatically create and publish posts using the REST API, but Basic Authentication seems to be causing conflicts with Application Passwords.
Current Setup and Attempts
- Environment Details:
- WordPress version: 5.6+
- Hosted on Afrihost with SSL enabled.
- Application Passwords are enabled and generated for the user.
- The Problem:
- REST API requests using Basic Authentication with Application Passwords consistently return:jsonCopy code
{"status":"error","error":"INVALID_PASSWORD","code":"400","error_description":"Incorrect password."}
- Using cURL:bashCopy code
curl --user "username:application_password" https://example.com/wp-json/wp/v2/posts -d '{"title":"Test Post"}' -H "Content-Type: application/json"
Response:vbnetCopy codecurl: (35) schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012)
- Using Python scripts and REST clients yields similar errors, either
401 Unauthorized
or 400 INVALID_PASSWORD
.
- Steps Taken:
- Verified Application Passwords:
- Generated multiple Application Passwords for the user.
- Confirmed the passwords were copied correctly without spaces.
- ModSecurity:
- Initially blocked requests but has since been whitelisted by the hosting provider.
- Basic Authentication Conflict:
- Suspected conflict due to staging environment protections using Basic Auth.
- Tested adding headers and removing site-level authentication to no avail.
- Error Analysis:
- Based on WordPress Trac Ticket #51939, there seems to be a known conflict where Application Passwords fail when Basic Auth is enabled at the server level.
What I’ve Tried
- Testing Alternative Headers:
- Tried sending requests with
Authorization: WP-App-Password
headers instead of Basic
.
- Result: No change in behavior.
- Added Custom Filters:
- Added filters such as
wp_is_application_passwords_available
to explicitly enable Application Passwords.
- Result: No improvement.
- Using a Plugin:
- Installed a custom REST API plugin to manage authentication flow, but the conflict persists.
Questions for the Community
- Is there a recommended workaround to bypass the Basic Auth conflict with Application Passwords, specifically for staging environments?
- Can Application Passwords be used alongside Basic Auth with any custom filters or headers?
- Are there alternative authentication methods (e.g., OAuth) that work better in such cases?
Any guidance or suggestions would be greatly appreciated. I’m happy to provide additional details or logs if needed.
Thank you in advance for your help!