What do you mean by “external users”?
If you only want Users, that are logged into your website, to use the API Endpoint, you can filter the “rest_authentication_errors” like described here
Add this to your plugin:
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
}
return $result;
});
Happy Coding!
Related Posts:
- How to: Make JWT-authenticated requests to the WordPress API
- WordPress Rest API: How do we validate with our custom API key?
- 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?
- WP REST API: check if user is logged in
- 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?
- Can’t GET draft posts via REST API from headless frontend
- Create Session with JWT
- 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
- WP REST API – Nonce passes wp_verify_nonce even after logout
- 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
- Rest API basic auth not working
- Authenticate current user to REST API
- Rest API: wp_verify_nonce() fails despite receiving correct nonce value
- 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
- WordPress HTTP API NTLM Authentication
- Advanced Access Manager: RESTful endpoint to refresh token
- Best Authetication between REST API and Mobile App
- Log in user using WordPress REST API
- Secure WordPress API, how?
- wp_nonce vs jwt
- register/login api
- How can I secure my custom rest api endpoint or add under a already existing rest group
- Register rest field authentication with REST API
- 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
- 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 Require Password for GET Endpoint
- WP REST API V2 – Retrieve sub page by full slug (URL/Path)
- How to check WordPress website username and password is correct
- How to build a plugin that supports authenticated POST requests to the REST API from external servers?
- How to use the WP REST API for new user registration (sign up form)?
- 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 and Custom Fields
- WordPress REST API, Expired Nonce from Cache results in 403 forbidden
- 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?
- Passing a borrowed nonce through Postman fails
- How to hook into “register_rest_field” to modify the behavior of a custom field?
- Get all PDF files from page with WordPress API
- 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
- WP_REST_Response() doesn’t seem to return the expected object
- Setting ?context=edit results in rest_forbidden_context, even for an Administrator user
- WP Rest Api- Update callback (POST request) to existing database table through the rest api
- Save default options as an array of options and display in REST API
- WordPress REST Api get posts by ID
- [Zapier + WP Webhooks Pro]: Custom Fields get cut off at first comma or semicolon
- Which route in the WP REST API do I access data passed into register_setting()?
- How to use Python to create a Post in WordPress?
- Send a get request to wordpress
- Replace content via rest api only?
- WP rest api endpoint protection using jwt token
- WP Rest API – Change response status code for failed validation request
- Unable to create a Rest end-point
- Can i fetch the list of pouplar posts of last 24 hours from WordPress API?
- WordPress Rest Api rest_cannot_edit
- how to create JSON array [] for REST response?
- Getting 401 unauthenticated error in WP Rest API revisions
- WordPress Custom Rest Api – How to get Image Url?
- Remote publishing using WP’s RetAPI // Issues with HTACCESS
- save_post hook error with REST API
- Connecting WordPress with an External API
- Users REST API not working?
- Using WordPress solely as a Backend – dealing with WP_SITEURL
- use WordPress Rest API to build a web application
- REST Request Post including meta/custom fields
- Why wp_set_password not working within a api endpoint?
- 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
- Script tag in string in wordpress rest api body to create post
- Customizer Changeset, Sidebar and Rest API Custom Endpoints