GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 401 Unauthorized response when using this plugin · Issue #53 · WP-API/Basic-Auth

401 Unauthorized response when using this plugin #53

New issue
Copy link
New issue
Copy link
Open
Open
401 Unauthorized response when using this plugin#53
Copy link

Description

@d0kt0r1
d0kt0r1
opened on Feb 13, 2018
Issue body actions

Hello,

I am making this request with Wordpress 4.9.4:

GET http://somehostname.com/index.php?rest_route=%2Fwp%2Fv2%2Fposts&per_page=100&page=2&context=edit HTTP/1.1
Host: somehostname.com
Authorization: Basic [****base64encoded username+":"+pass *******]
Accept-Encoding: gzip, deflate
User-Agent: [some user agent name]

And I get this response:

HTTP/1.1 401 Unauthorized
Date: Tue, 13 Feb 2018 14:26:12 GMT
Server: Apache
X-Powered-By: PHP/7.1.12
X-Robots-Tag: noindex
Link: <http://somehostname.com/wp-json/>; rel="https://api.w.org/"
X-Content-Type-Options: nosniff
Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages
Access-Control-Allow-Headers: Authorization, Content-Type
Vary: Accept-Encoding,User-Agent
Content-Length: 127
Content-Type: application/json; charset=UTF-8

{"code":"rest_forbidden_context","message":"Sorry, you are not allowed to edit posts in this post type.","data":{"status":401}}

Activity

  1. BrianHenryIE commented on Feb 14, 2018

    @BrianHenryIE
    BrianHenryIE
    on Feb 14, 2018
    More actions

    It looks like this plugin is working fine, i.e. the user is authenticated, but the user is not permitted to edit posts, i.e not authorised.

    Take a look at the code that (I think) is returning that message:
    https://github.com/WordPress/WordPress/blob/91464bce658541193a47886e0e5041c27f25851a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L125-L141

    Whatever user you're authenticating as doesn't have edit permission on any posts. You might just want to change your request to context=view, or elsewhere – via a plugin or functions.php – you can give them the capability.

  2. d0kt0r1 commented on Feb 15, 2018

    @d0kt0r1
    d0kt0r1
    on Feb 15, 2018
    Author
    More actions

    No. I got this fixed just now by doing as this comment is suggesting:
    #35 (comment)

    Not sure if this fix has any side effects though?

    Reacted by Vladimir Stajilov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.