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
- How to add additional http header to a wp_error rest response
- Is the WordPress REST API installed and enabled in a vanilla WordPress 4.7 installation?
- Does something like is_rest() exist
- How to use OAuth authentication with REST API via CURL commands?
- REST API purpose?
- Get post count in wp rest API v2 and get all categories
- WP REST API — How to change HTTP Response status code?
- wp_get_current_user() function not working in Rest API callback function
- How to use WP-REST API to login user and get user data for Android app?
- WP REST API Is it rather easy to rename the default wp-json uri part?
- Search WP API using the post title
- check the requesting url
- How would I add custom tables/endpoints to the WP REST API?
- WP REST API Require Password for GET Endpoint
- Displaying a page built with Elementor using the REST API [closed]
- Getting user meta data from WP REST API
- Understanding SHORTINIT with WordPress 5
- How to use _embed when using _fields?
- WordPress REST API – Permission Callbacks
- WP REST API V2 – Retrieve sub page by full slug (URL/Path)
- WP REST API create post authentication issue
- Why is my custom API endpoint not working?
- WordPress REST API validation
- Are there server performance benefits to fetching only specific fields when querying the REST API?
- How to define a query parameter with REST API?
- Filter posts by multiple custom taxonomy terms using AND operator in REST API v2 (WordPress)
- WP REST API returns blank response if post is too long
- How do I correctly setup an AJAX nonce for WordPress REST API?
- how to authenticate for the REST API from a plugin and from command line
- How to check WordPress website username and password is correct
- Increase per_page limit in REST API
- Does pre_get_posts affect REST API responses?
- How to feed a HTML5’s EventSource with a REST API custom endpoint?
- How do I use the WP REST API plugin and the OAuth Server plugin to allow for registration and login?
- Adding WordPress API Endpoint With Multiple Parameters
- How to authenticate custom API endpoint in WooCommerce [closed]
- WordPress REST API call generates nonce twice on every call
- Retrieve CSS and JS From the REST API
- Using the REST API (v2) javascript client on a private namespaced route
- WP REST API core major changes
- WordPress 4.7 REST API endpoints
- How to get all posts from parent and children categories?
- wordpress wp-json prefix issue
- How to build a plugin that supports authenticated POST requests to the REST API from external servers?
- Hiding API routes list
- Get blog title with REST v2
- Is it possible to nest the JSON result of WordPress REST API?
- Match REST API post output from custom endpoint
- How to use the WP REST API for new user registration (sign up form)?
- REST API multiple media upload
- Filter post_content before loading in Gutenberg editor
- Attach featured image to custom endpoints
- Can’t send emails through REST API
- 401 Error when trying to make a REST API call to site
- WordPress: How to create custom REST API route?
- Create post using rest api with html content
- Does jQuery/Ajax send cookies when using the rest API or do I need to somehow add them?
- How to change user avatar using REST API?
- Android authentication