[wp-trac] [WordPress Trac] #38521: REST API: Get rid of the `/users/me` redirect

WordPress Trac noreply at wordpress.org
Wed Oct 26 21:04:38 UTC 2016


#38521: REST API: Get rid of the `/users/me` redirect
--------------------------+-----------------------------
 Reporter:  jnylen0       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 From @youknowriad [https://wordpress.slack.com/archives/core-
 restapi/p1477493575009830 in Slack]:

 > Hi! I noticed something in the API, not sure if it's a bug or not. When
 performing a request to `/users/me` I'm redirected to `/users/1` (seems
 logic because the user with id 1 is me).
 > But I'm using CORS to tackle the API via OAuth1 and CORS disallow
 redirects if the request require preflight.
 > So the /me is not working unless I call directly `/users/1`
 > Maybe the `/me` should not redirect but gives the user object directly ?

 There is even a special section in the docs about this:  http://v2.wp-
 api.org/guide/problems/#authentication-errors-with-usersme

 I understand that we don't want to duplicate resources across API URLs.
 However, this redirect is breaking things for a pretty common use-case of
 this endpoint (any application that runs in a browser on a different
 domain than the WP site) and we should remove it.

 We already have a mechanism to indicate the canonical location of a
 resource: `response._links.self[0].href`.  Let's use that instead.

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


More information about the wp-trac mailing list