WordPress / application-passwords

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't post an article

jtosey opened this issue · comments

I'm unable to post an article to a test server, and cannot figure out why.

I installed this plugin and it shows:

Username      osadmin
...
Your new password for omnistream: tSp0 nelJ bZQt 39zC

Name          Created                  Last   Used   Last IP   Revoke
omnistream    February 9, 2016 ...

This works:
$ curl http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts/268

This does not:

$ echo -n "osadmin:tSp0 nelJ bZQt 39zC" | base64
b3NhZG1pbjp0U3AwIG5lbEogYlpRdCAzOXpD
$ curl --header "Authorization: Basic b3NhZG1pbjp0U3AwIG5lbEogYlpRdCAzOXpD" -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts
{"code":"rest_cannot_create","message":"Sorry, you are not allowed to create new posts.","data":{"status":401}
$ 

If I try without the spaces:

$ echo -n "osadmin:tSp0nelJbZQt39zC" | base64
b3NhZG1pbjp0U3AwbmVsSmJaUXQzOXpD
$ curl --header "Authorization: Basic b3NhZG1pbjp0U3AwbmVsSmJaUXQzOXpD" -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts
{"code":"rest_cannot_create","message":"Sorry, you are not allowed to create new posts.","data":{"status":401}}
$ 

What am I doing wrong?

I've changed the password since posting this (for security reasons) but would happy to send it to you out of band if you need it.

I think you have to specify a post ID to update within the URL. Try to change this

curl --header "Authorization: Basic b3NhZG1pbjp0U3AwIG5lbEogYlpRdCAzOXpD" -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts

to this

curl --header "Authorization: Basic b3NhZG1pbjp0U3AwIG5lbEogYlpRdCAzOXpD" -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts/268

If I include the :id, then the post is interpreted as an edit, otherwise a create - but both fail. Here is the current key - give it a try. I'm not sure whether to include the spaces in the password - I assume they should not be included.

I'm hosting this on GoDaddy - could they be doing something that prevents this from working?

$ curl --user 'osadmin:6o9oRJR0BHz1D1qf' -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts
{"code":"rest_cannot_create","message":"Sorry, you are not allowed to create new posts.","data":{"status":401}}

$ curl --user 'osadmin:6o9oRJR0BHz1D1qf' -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts/268
{"code":"rest_cannot_edit","message":"Sorry, you are not allowed to update this post.","data":{"status":401}}

On Feb 9, 2016, at 9:59 AM, Kyle Benk notifications@github.com wrote:

I think you have to specify a post ID to update within the URL. Try to change this

curl --header "Authorization: Basic b3NhZG1pbjp0U3AwIG5lbEogYlpRdCAzOXpD" -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts
to this

curl --header "Authorization: Basic b3NhZG1pbjp0U3AwIG5lbEogYlpRdCAzOXpD" -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts/268

Reply to this email directly or view it on GitHub #25 (comment).

Oh ok I mis-read your first post and I thought you were trying to update a post. Either way please confirm that you are able to create a new post using the Basic Auth Plugin. If that works then it might be a problem with Application Passwords.

No, that doesn't work either (blanking password for this email):

$ curl --user 'osadmin:********' -X POST -d "title=New Title" http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/posts
{"code":"rest_cannot_create","message":"Sorry, you are not allowed to create new posts.","data":{"status":401}}

Any suggestions how to find out why it wouldn't work?

On Feb 9, 2016, at 10:15 AM, Kyle Benk notifications@github.com wrote:

Oh ok I mis-read your first post and I thought you were trying to update a post. Either way please confirm that you are able to create a new post using the Basic Auth Plugin https://github.com/WP-API/Basic-Auth. If that works then it might be a problem with Application Passwords.


Reply to this email directly or view it on GitHub #25 (comment).

Please confirm that you were able to authenticate using the plugin by following the steps here. After that I would look into making sure that the user you are authenticating with has permission to create a new post.

Finally, try to deactivate all other plugins within your site and activate a default wordpress theme and then see if works.

I did try that - the problem is that this works whether the password is correct or incorrect. It doesn't actually prove that I've authenticated.

Works:
$ curl --user 'osadmin:*******' http://aaatalks.carolinas.aaa.com/wp-json

Works too:
$ curl http://aaatalks.carolinas.aaa.com/wp-json

So, the only way I know to test authentication is to attempt to modify an object:

$ curl --user 'osadmin:********' -X POST http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/users/1
{"code":"rest_cannot_edit","message":"Sorry, you are not allowed to edit users.","data":{"status":401}}

$ curl --user 'osadmin:********' -d 'name=test' -X POST http://aaatalks.carolinas.aa
{"code":"rest_cannot_create","message":"Sorry, you cannot create new terms.","data":{"status":401}}

Incidentally, I am authenticating as an admin, which does have permission to create posts - I can do that through the UI.

On Feb 9, 2016, at 10:31 AM, Kyle Benk notifications@github.com wrote:

Please confirm that you were able to authenticate using the plugin by following the steps here https://github.com/WP-API/Basic-Auth#using. After that I would look into making sure that the user you are authenticating with has permission to create a new post.

Finally, try to deactivate all other plugins within your site and activate a default wordpress theme and then see if works.


Reply to this email directly or view it on GitHub #25 (comment).

I tried this on Bluehost, and it works, using a copy of my site. GoDaddy must be filtering out this header. I'll follow up with them.

Thank you for your help!

On Feb 9, 2016, at 10:43 AM, Joseph Tosey jtosey@gmail.com wrote:

I did try that - the problem is that this works whether the password is correct or incorrect. It doesn't actually prove that I've authenticated.

Works:
$ curl --user 'osadmin:*******' http://aaatalks.carolinas.aaa.com/wp-json http://aaatalks.carolinas.aaa.com/wp-json

Works too:
$ curl http://aaatalks.carolinas.aaa.com/wp-json http://aaatalks.carolinas.aaa.com/wp-json

So, the only way I know to test authentication is to attempt to modify an object:

$ curl --user 'osadmin:********' -X POST http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/users/1 http://aaatalks.carolinas.aaa.com/wp-json/wp/v2/users/1
{"code":"rest_cannot_edit","message":"Sorry, you are not allowed to edit users.","data":{"status":401}}

$ curl --user 'osadmin:********' -d 'name=test' -X POST http://aaatalks.carolinas.aa http://aaatalks.carolinas.aa/
{"code":"rest_cannot_create","message":"Sorry, you cannot create new terms.","data":{"status":401}}

Incidentally, I am authenticating as an admin, which does have permission to create posts - I can do that through the UI.

On Feb 9, 2016, at 10:31 AM, Kyle Benk <notifications@github.com mailto:notifications@github.com> wrote:

Please confirm that you were able to authenticate using the plugin by following the steps here https://github.com/WP-API/Basic-Auth#using. After that I would look into making sure that the user you are authenticating with has permission to create a new post.

Finally, try to deactivate all other plugins within your site and activate a default wordpress theme and then see if works.


Reply to this email directly or view it on GitHub #25 (comment).

Great :)

This was a hosting issue and therefore not released to the plugin. @jtosey can you please close this issue :)