WP-API / example-client

MIT License
79 stars 20 forks source link

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

Closed bigandy closed 8 years ago

bigandy commented 8 years ago

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.

tollmanz commented 8 years ago

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.

rmccue commented 8 years ago

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