client-cli icon indicating copy to clipboard operation
client-cli copied to clipboard

Can't OAuth1 Connect

Open tlovett1 opened this issue 11 years ago • 13 comments

I am running this on my local VVV install:

First I ran the following command:

wp --url=http://local.vistage.dev/southwest oauth1 add

Result:

ID: 2516
Key: SXh2rc4SaIIb
Secret: nDtR5t0qgzSLU472SDN6Js8LEU0WEINkkN7BLfhyxVIJGQdu

Then I ran the following:

wp --require=client.php api oauth1 connect http://local.vistage.dev/southwest --key=SXh2rc4SaIIb --secret=nDtR5t0qgzSLU472SDN6Js8LEU0WEINkkN7BLfhyxVIJGQdu

Result:

Error: 401 Unauthorized

tlovett1 avatar Jun 18 '14 04:06 tlovett1

Im getting a Error: 400 Bad Request at the same point as @tlovett1

callerc1 avatar Jun 24 '14 11:06 callerc1

Any word on what's happening here? I'm getting Error: 400 Bad Request, too.

brandondurham avatar Sep 06 '14 22:09 brandondurham

It seems it's losing the oauth parameters along the way when building the request. Can't figure out where though.

Status text on the 400 response is No OAuth parameters supplied

ghost avatar Sep 27 '14 14:09 ghost

I tried this again and was able to authorize my application. Not sure what happened before.

tlovett1 avatar Sep 27 '14 16:09 tlovett1

Same problem here. Getting 400 response and No OAuth parameters supplied. I'm running a local apache server under Windows. HTTP_AUTHORIZATION was not being set in the global $SERVER array. In StackOverflow I found someone reporting a similar problem. http://stackoverflow.com/questions/13387516/authorization-header-missing-in-django-rest-framework-is-apache-to-blame The solution was to include a rewrite rule. RewriteCond %{HTTP:Authorization} ^(.) RewriteRule ._ - [e=HTTP_AUTHORIZATION:%1]

This has got me past the 400 No OAuth parameters supplied.

I then got the 401 Unauthorized: OAuth signature does not match

I have discovered that the client "string_to_sign" was different from the one that that server had created. The problem appears to be associated with a subdirectory install.

I made a minor change to OAuth1/lib/class-wp-json-authentication-oauth1.php replacing

$base_request_uri = rawurlencode( get_home_url( null, parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ), 'http' ) ); with

$base_request_uri = rawurlencode( $_SERVER['HTTP_REFERER'] );

And now I've finally got to the

Open in your browser: http://qw/wp40/oauth1/authorize?oauth_token=something

Hurrah!

Whether or not it's safe to use HTTP_REFERER is open for discussion. BTW. In this environment siteurl and home are: http://qw/wp40 $_SERVER['REQUEST_URI'] was /wp40/oauth1/request $_SERVER['HTTP_REFERER'] was http://qw/wp40/oauth1/request

bobbingwide avatar Oct 13 '14 13:10 bobbingwide

BTW. The 401 part of this problem appears to be a duplicate of https://github.com/WP-API/OAuth1/pull/32

bobbingwide avatar Oct 13 '14 21:10 bobbingwide

I have successfully installed everything, however it's not possible to finish the script as I'm seeing an "Error: 400 Bad Request" whenever I try to connect a customer.. Has anyone a solution for this?

manonthemoon avatar Nov 20 '14 00:11 manonthemoon

I'm running into the same problem, just getting Error: 400 bad request. Tried everything bobbingwide mentioned with no success. Any other suggestions would be great.

WCByrne avatar Feb 04 '15 19:02 WCByrne

Me too, I am stuck with the 400 error. I'd appreciate more information on setting the rewrite condition. I am running the client on OS X.

kieranhall avatar Feb 07 '15 13:02 kieranhall

Trying this again today after no changes and am getting a different error, 1Could not locate OAuth information; are you sure it's enabled?`. the plugin appears active. Any suggestions?

WCByrne avatar Feb 09 '15 19:02 WCByrne

"Could not locate OAuth information; are you sure it's enabled?" means you haven't OAuth plugin or the plugin is in detective.

nfer avatar Sep 22 '15 16:09 nfer

Error: Could not locate API; are you sure it's enabled?

tried in 2 different wp setup, local and online

I'm sure the wp-rest-api beta2 and oauth1 plugin are installed and active i can see authentication properties in the wp-json/ response

any help please?

gino8080 avatar Jan 19 '16 10:01 gino8080

I am also facing the same issue. Can anyone help me asap?

NileshSystematix avatar Jun 28 '17 11:06 NileshSystematix