WP-API/example-client

Site doesn't appear to support OAuth 1.0a authentication.

bigandy opened this issue · 2 comments

Installed the Oauth1 plugin and tried this on a dev site and also live site e.g. https://big-andy.co.uk/ both getting the same Site doesn't appear to support OAuth 1.0a authentication. message.

I got this problem too. I tracked it down to WordPress\Discovery\Site. The getSupportedAuthentication() method runs this check:

if ( empty( $this->data->authentication ) || ! is_array( $this->data->authentication ) ) {

Turns out, $this->data->authentication is an instance of stdClass. I changed the check to is_object and cast the return value to array and it is working for me:

public function getSupportedAuthentication() {
    if ( empty( $this->data->authentication ) || ! is_object( $this->data->authentication ) ) {
        return array();
    }

    return (array) $this->data->authentication;
}

@rmccue Not sure if this is the fault of this sample project or the underlying library. Hoping this is a simple fix for you. My change gets things working, but I'm not sure where the type confusion is happening.

You are entirely correct; I made this change locally, and then never pushed the changes. Sorry about that.