• Resolved atoomic

    (@atoomic)


    Hi, I’m trying to use the REST API for the WP Super Cache plugin.

    After reading the “rest/load.php” which plugs the routes, my understanding is that some valid routes are:
    /wp-super-cache/v1/settings
    /wp-super-cache/v1/plugins

    But if my domain is mydomain.test after login to mydomain.test/wp-admin as an admin user, I cannot get any of the API endpoint work.

    What am I missing?

    For example: https://mydomain.test/wp-json/wp/v2/users works fine but
    https://mydomain.test/wp-json/wp-super-cache/v1/settings
    or https://mydomain.test/wp-json/wp-super-cache/v1/settings

    are returning a 401 error with incorrect permissions

    {"code":"rest_forbidden","message":"Sorry, you are not allowed to do that.","data":{"status":401}}

    I do not see any notions of user for that plugin and was thinking that the admin user could call any of these API endpoints.

    Any idea what I am doing wrong there?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter atoomic

    (@atoomic)

    I was able to solve my issue using Application Password, and then using Basic Authentication to submit the request.

    Looks like the session cookie is not enough on a browser and you probably need a nonce id also. This is why it was not working from the browser using an authenticated user.

    How To Get An Application Password:

    As of 5.6, WordPress has shipped with Application Passwords, which can be generated from an Edit User page (wp-admin -> Users -> Edit User).

    Alternatively you can use the CLI to generate / refresh the app password
    https://developer.ww.wp.xz.cn/cli/commands/user/application-password/

    Then you can use it as described here
    https://developer.ww.wp.xz.cn/rest-api/using-the-rest-api/authentication/

    curl -k --user 'username:YourOneTimePass' https://your-domain.test/wp-json/wp-super-cache/v1/settings

    Hi @atoomic,

    Thanks for reaching out and then sharing the solution to the issue also 🙂.

    Please feel free to contact us if you have any other questions.

    Best,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WP Super Cache REST API’ is closed to new replies.