WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] Unauthorized User - Cannot Publish (6 posts)

  1. riginosg
    Member
    Posted 8 months ago #

    Hello everyone!

    I'm trying to create a new post using the JSON API by making a cURL request.

    I have added the authorisation token on the http header but get the following error:

    {"error":"unauthorized","message":"User cannot publish posts"}

    When I try doing a get (getting all posts for examples) it works fine. On my website back-end the user I am using has admin privileges. However, when I go to developer.wordpress…. etc. to the security section and click on my website's connected application it says that my access permissions are:

    "View user information data such as username, name, email, blog and Gravatar."

    Might that be the problem??

    http://wordpress.org/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 8 months ago #

    In order to post using the JSON API, you'll need to authenticate first, using OAuth2.

    You can read more about it here:
    https://developer.wordpress.com/docs/oauth2/

    You could have a look at how Open Source applications like StackEdit do to manage authentication to post to a Jetpack site. Here is how they handle the authentication:
    https://github.com/benweet/stackedit/blob/master/public/res/helpers/wordpressHelper.js

  3. riginosg
    Member
    Posted 7 months ago #

    Jeremy,

    Thanks for the reply! I do use OAuth2 to authenticate. Do you have any examples on how I can do this using CURL?

    Thanks,

    George

  4. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 7 months ago #

    Our documentation provides examples of how to authenticate with a token you get via curl:
    https://developer.wordpress.com/docs/oauth2/

  5. riginosg
    Member
    Posted 7 months ago #

    Thanks Jeremy! I'm already doing this. The problem is that I would like to be able to authorise my application without having to get into this intermediary screen where I have to actually click "Authorize". How can I do that?

  6. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 7 months ago #

    You do indeed have to authorize the app to use your WordPress.com account. That's a necessary step for people to use your app.

    If you need more details, could you send us an email with more details about your app here:
    http://developer.wordpress.com/contact/

    Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic