WP-API / OAuth1

OAuth server implementation for WP API
http://oauth1.wp-api.org/
327 stars 109 forks source link

Athenticated requests return 401 when Wordpress cookies are available #208

Open mateuswetah opened 7 years ago

mateuswetah commented 7 years ago

I'm using Ionic to implement an App for accessing a Wordpress blog using WP-API and Oauth1.

My work flow for obtaining the tokens went fine and I can confirm that they're valid. The only problem is that, if I try to do any authenticated request (for example, GET to /users/me), I have a status 401 with the code "rest_not_logged_in". It took me a time to figure out that if I had my cookies cleared the problem would be solved. The cookies are related to Wordpress session login, performed during authorize step with the user.

I was able to solve it performing a wp_logout on my calllback URL, but still, it's not pretty... can anyone explain me why this happens?

Thanks in advance.

muraliwebworld commented 6 years ago

Yes I have also faced same problem it returned 401 while creating post from cordova app. After analyzing i found that the function rest_oauth1_force_reauthentication which issues return when user is already logged on due to which it is not authenticating properly. This plugin needs to be updated so that it will authenticate properly after authorize or as you said it needs to perform logout before other request after authorization to re-authenticate users using token