• I need to call wordpress endpoints from outside without basic auth. So I used api key for that. I defined my api key inside the config file. I am able to get main user details by calling the below endpoint.
    https://mysite.com/wp-json/wp/v2/users/1
    But I am getting a n error while calling for another user as follows
    https://mysite.com/wp-json/wp/v2/users/2
    Error:
    ‘code’: ‘rest_user_cannot_view’,
    ‘message’: ‘Sorry, you are not allowed to list users.’,
    ‘data’: {
    ‘status’: 401
    }
    How I can authorize the API key for all users? Please help
    Or please tell any other method for api calls without using username and password

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    API key? Do you mean application password? If so whose application password did you use? It needs to be an application password belonging to an admin user. Alternately, there are a couple other ways to authenticate API requests. See
    https://developer.ww.wp.xz.cn/rest-api/using-the-rest-api/authentication/#authentication-plugins

    Thread Starter anithajayan

    (@anithajayan)

    @bcworkz

    Thank you for your reply.

    Yes, How can I authorize the same application password for all the users?

    I need to retrieve the data using the bearer token without username and password

    Moderator bcworkz

    (@bcworkz)

    The application password is assigned to the app. App users have no bearing on usage. The app uses the same password for all requests regardless of user.

    It’s possible to get privileged data without authentication through a custom API route/endpoint, but doing so would likely introduce a significant privacy and/or security breach. There are good reasons we need authentication to get certain kinds of data.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Authorize API key’ is closed to new replies.