0

Using Wordpress's plugin WP REST API version 1, there is an endpoint called /users/me which response with data for the currently logged-in user. When I requested /users/me I got 403 Request Forbidden error. But If I requested /users/1 (where 1 is the user ID) then everything works. So why am I getting 403 error for /users/me endpoints? I'm using Postman to send my request:

THIS WORKS (userID 1 is the currently logged-in user):

http://example.com/wp-json/users/1?access_token={myAccessToken}

DOESN'T WORK:

http://example.com/wp-json/users/me?access_token={myAccessToken}

However, when using WP REST API version 2, /users/me works but it only returns a subset of what version 1 would have returned. The data is incomplete by comparison (i.e. email, first name, last name ...etc)

http://example.com/wp-json/wp/v2/users/me?access_token={myAccessToken}

{
    "avatar_urls": {
        "24": "http://2.gravatar.com/avatar/29b3ef85f13fedb43f84e6cb4a634e73?s=24&d=mm&r=g",
        "48": "http://2.gravatar.com/avatar/29b3ef85f13fedb43f84e6cb4a634e73?s=48&d=mm&r=g",
        "96": "http://2.gravatar.com/avatar/29b3ef85f13fedb43f84e6cb4a634e73?s=96&d=mm&r=g"
    },
    "description": "",
    "id": 1,
    "link": "http://example.com/author/admin/",
    "name": "admin",
    "url": "",
    "_links": {
        "self": [
            {
                "href": "http://example.com/wp-json/wp/v2/users/1"
            }
        ],
        "collection": [
            {
                "href": "http://example.com/wp-json/wp/v2/users"
            }
        ]
    }
}
0

The subset of data you are seeing is the publicly available author data. ie. if a user has published content on the site, their name, gravatar and description is deemed public data and available to un-authenticated requests.

If you're seeing this user data you can assume the access_token is invalid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.