It is a bad API design to return different structure based on “external data” not passed in the request itself.
Either construct different API for logged in users and use a different end point for it, or return a “filler” when the user do not have permission to access the data.
(and it is always a bad idea to make modifications to the official rest API as you might create incompatibilities with other users of it, so at least be careful use prefixes etc)
Related Posts:
- WP REST API: check if user is logged in
- Can’t GET draft posts via REST API from headless frontend
- WP REST API – Nonce passes wp_verify_nonce even after logout
- Rest API: wp_verify_nonce() fails despite receiving correct nonce value
- Log in user using WordPress REST API
- wp_nonce vs jwt
- How to: Make JWT-authenticated requests to the WordPress API
- WordPress Rest API: How do we validate with our custom API key?
- WordPress REST API call generates nonce twice on every call
- How to Authenticate WP REST API with JWT Authentication using Fetch API
- authentication issue with rest api – rest_cannot_create
- Can I authenticate with both WooCommerce consumer key and JWT?
- How to login to WordPress site using basic authentication HTTP headers?
- Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Create Session with JWT
- Full page NGINX (or Cloudflare) caching and WordPress nonces
- WordPress REST API, Expired Nonce from Cache results in 403 forbidden
- Passing a borrowed nonce through Postman fails
- how to send Ajax request in wordpress backend
- permission_callback has no effect
- WP REST API GET Requests require authentication
- current_user_can(‘administrator’) returns false when I’m logged in
- Authenticating with REST API
- Make authorization mandatory on custom routes
- How to force JWT auth for default GET endpoints of WordPress rest api?
- REST API: best place to set current user for JWT auth?
- WordPress + REST API v2 and private pages Load by slug
- REST API authentication for a plugin
- PHP: authenticate for a REST request?
- Rest API basic auth not working
- Authenticate current user to REST API
- Getting 401 from ajax using an application password
- How to connect android app with WordPress website?
- WordPress REST API calls that depend on the WordPress User
- Backbone with custom rest endpoints
- WordPress HTTP API NTLM Authentication
- Advanced Access Manager: RESTful endpoint to refresh token
- Best Authetication between REST API and Mobile App
- How to verify which WordPress user requested the API in ASP .NET Core?
- Secure WordPress API, how?
- register/login api
- How can I secure my custom rest api endpoint or add under a already existing rest group
- REST API Integration without user account?
- WP REST API with Basic Auth at target website
- Cant POST with REST API on WordPress
- REST API – Authentication/Logon security
- Rest API nonce is being cached
- custom REST endpoints and application passwords
- wordpress rest api authentication failed
- Is the WordPress REST API installed and enabled in a vanilla WordPress 4.7 installation?
- check the requesting url
- WP REST API V2 – Retrieve sub page by full slug (URL/Path)
- How to check WordPress website username and password is correct
- Adding post fields in wp-json/wp/v2/search
- Unable to get the info of the user which doesn’t have created any post via REST API
- WordPress Gutenberg get page template value when post updated?
- How to update custom meta fields with rest api?
- Rest API invalid nonce with Backbone Client
- Rest API and Custom Fields
- WP Rest API: Get User by Email
- Gutenberg Custom Block Getting All Posts
- Can we assume that /wp-json/ will always be /wp-json/ under any circumstances when creating custom REST routes?
- How to hook into “register_rest_field” to modify the behavior of a custom field?
- How to add / embed an author into REST data from a custom post type?
- How to enable the view of revisions of post in WordPress Api for custom post type?
- Problem on creating custom endpoints for REST
- Rest API code to get ID of current user not working: get_current_user_id() gives 0
- New user signup via REST API
- Ho to style post content for WordPress API?
- WP REST API can’t set post tags
- WP API post__not_in is not working
- Sidebar endpoint using WordPress API
- Get custom posts in gutenberg block
- Getting 401 (access denied) when trying to use the REST API
- WordPress REST API not working on localhost
- User following system via REST API
- REST API – Allow /users endpoint depending on a custom capability
- Can I overwrite default WordPress Json API For no more pages text
- Create User with Profile and Cover Images using REST API
- Media gallery images url instead of ID on WP API
- What’s the right way to validate JSON data coming from an AJAX POST request?
- Remove unwanted fields from WP API response
- WordPress API “code”:”rest_no_route” with Custom Route
- WordPress Update Role using API Cross site
- Rest API. Post content
- Error rest_post_invalid_page_number trying to call Rest API
- Is it possible to combine two rest endpoints in the url?
- WordPress api returns distinct data
- Redefine REST API variables
- Where is the HTML content for my post in the API
- WordPress Rest API Escapes Returned URLs Forward Slash
- Update post / page using API + python
- Social login authentication via wordpress rest api
- Calling a Rest API with parameters on button Click
- WordPress json – How to use the content rendered from json
- Subscriber role cann’t add comment meta using REST API
- WordPress REST API function not calling from external site
- Issue with API after 6.2 update
- Verify user login and password over api