Automattic / Automattic/wordpress-rs

Failed authentication for `WpComApiClient` triggers `/application-passwords/introspect` check

Open
#776 0 comments 0 reactions 1 assignee Claimed by @oguzkocer View on GitHub
Bug
Dominant language
Rust
Stars
36
Forks
5
Avg merge
17h 30m
Merged PRs (30d)
43

Description

If a `WpComApiClient` request fails with authentication error, it triggers the [`/application-passwords/introspect`](https://developer.wordpress.org/rest-api/reference/application-passwords/#retrieve-a-application-password-2) check. This will result in a crash, [because](https://github.com/Automattic/wordpress-rs/blob/6ad6a379792552f1559809c20fba74009bd00ce9/wp_api/src/wp_com/endpoint.rs#L78-L81) it uses the `/wp/v2` namespace.

Here is a Kotlin integration test to trigger the issue:

```Kotlin
val authProvider = WpAuthenticationProvider.staticWithUsernameAndPassword(
username = "foo", password = "bar"
)
val wpComClient = WpComApiClient(WpAuthenticationProvider.staticWithAuth(WpAuthentication.Bearer(token = "")))
val subscriberList = wpComClient.request { requestBuilder ->
requestBuilder.subscribers().listSubscribers(wpComSiteId = 1111u, params = SubscribersListParams())
}.assertSuccessAndRetrieveData().data
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.