[wp-trac] [WordPress Trac] #40494: /wp-json/wp/v2/users/me api endpoint (it's part of the core now) returns 401 not logged in

WordPress Trac noreply at wordpress.org
Thu Apr 20 12:33:02 UTC 2017


#40494: /wp-json/wp/v2/users/me api endpoint (it's part of the core now) returns
401 not logged in
--------------------------+-----------------------------
 Reporter:  asudakov      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  4.7.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Clean installation.
 One user, logged in under it.
 /wp-json/wp/v2/users/me
 returns:
 {"code":"rest_not_logged_in","message":"You are not currently logged
 in.","data":{"status":401}}

 It's not redirect, it's looks like get_current_user_id() returned zero as
 a result (details on this guess below).

 While
 /wp-json/wp/v2/users/1
 returns normal message starting with:
 {"id":1,"name":"alex.sudakov","url":"","description":""

 In 4.6 release, while rest API was a plugin, I could debug it and found
 out, that get_current_user_id() returned 0 (In get_current_item function).
 I couldn't hunt this down. But I checked that this function result is
 affected in other endpoints as well (checking permissions
 (get_item_permissions_check) for example).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40494>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list