Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#42715 closed defect (bug) (worksforme)

Incorrect results for http://demo.wp-api.org/wp-json/wp/v2/users/me endpoint

Reported by: kishores's profile kishores Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9
Component: REST API Keywords:
Focuses: Cc:

Description

I'm encountering inconsistent data returned from /wp-json/wp/v2/users/me endpoint when calling the end point. The get_current_user_id() always return 0, even though I am already logged in.

Well after doing login, apply_filters( 'determine_current_user', false ) returning correct user ID but get_current_user_id() gives 0. I am doing login using rest api with Basic Auth plugin.

@ref https://github.com/WP-API/WP-API/issues/1640

Change History (2)

#1 @dd32
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hey @kishores,

This is working fine for me, and looking at the linked discussion, it sounds like you're not properly authenticated to the API - maybe because the Authentication plugin you're using isn't fully compatible.

As this is working fine for me in core, using the cookie/nonce authentication (which you should try to get working first) I'm going to assume that it's likely the plugin is at fault, in which case reporting the issue to https://github.com/WP-API/Basic-Auth is your best method (It looks like lots of people have issues with the plugin)

#2 @dd32
6 years ago

  • Resolution changed from invalid to worksforme
Note: See TracTickets for help on using tickets.